Message 342857 - Python tracker

Message342857

Author apoorvreddy
Recipients apoorvreddy, larry, tehybel
Date 2019-05-19.14:22:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558275730.97.0.480908890607.issue36963@roundup.psfhosted.org>
In-reply-to
Content
Greetings Larry !

I apologize for spamming so many people. I was hoping to get some insight into this ! Could you let me know to whom I could reach out for help ? I've included tehybel as I saw that he has raised/resolved some issues with PyDict in the past.

My C code is essentially just this:

#include "Python.h"

#ifdef __cplusplus
extern "C" double test(PyObject* key, PyObject* dict)
#else
double test(PyObject* key, PyObject* dict)
#endif
{
	PyObject* list = PyObject_GetItem(dict, key);
	return 0.0;
}

------------

And my Python Code is this. I'm pretty sure I've got the input and output types correct here.

from ctypes import cdll
from ctypes import *
import json
import sys
import pickle


dll = CDLL('./test2.so')
dll.test.restype = c_double
dll.test.argtypes = (py_object, py_object)

d = {68113113140: [1, 2]}
for i in d.keys():
	if i == 68113113140:
		break
print(dll.test(i, d)) # this works just fine
print(dll.test(68113113140, d) # this segfaults !

GDB shows me that PyObject_RichCompare (called inside PyDict_GetItem) is the function where the segmentation fault happens !
--------

Hoping for some guidance here ! I've been trying to resolve this for 3 days now. I have made sure that I've compiled with the correct version of Python headers and that I'm using the same version of interpreter as well (in this case Python 3.5.6)
History
Date User Action Args
2019-05-19 14:22:10apoorvreddysetrecipients: + apoorvreddy, larry, tehybel
2019-05-19 14:22:10apoorvreddysetmessageid: <1558275730.97.0.480908890607.issue36963@roundup.psfhosted.org>
2019-05-19 14:22:10apoorvreddylinkissue36963 messages
2019-05-19 14:22:10apoorvreddycreate