Author karczex
Recipients karczex
Date 2020-01-09.13:52:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
How to reproduce:

1. Create callback function, which may take any object and run type() on it
  def builtin_type_in_callback(obj):

2. Create C extension with two types defined in it - Internal and External. 
  Eternal type should implement method (let's name it Call), which can get callback function

		static PyObject *
		Call(ExternalObject *self, PyObject* args) {
		PyObject* python_callback;
		if (!PyArg_ParseTuple(args, "O:set_callback",  &python_callback)) {
			return NULL;
		if(PyErr_Occurred() != NULL)
			return NULL;
  Inside this function create object of Internal type and pass it to callback function
	void callback_runner(void* callback_function)  {
		InternalObject *entry = PyObject_New(InternalObject, &InternalType);
		PyObject_Init((PyObject*)entry, &InternalType);
		PyObject *args = PyTuple_New(1);
		if (args != NULL) {
			if (PyTuple_SetItem(args, 0, (PyObject *)entry) == 0) {
				PyObject *res = PyObject_CallObject((PyObject *) callback_function, args);
When type() is called on object of Internal type segmentation fault occur. However, if dir() was called
on such object before type(), type() works properly and returns type of Internal Object.

For more details please look into reproducer code.
Date User Action Args
2020-01-09 13:52:14karczexsetrecipients: + karczex
2020-01-09 13:52:14karczexsetmessageid: <>
2020-01-09 13:52:13karczexlinkissue39276 messages
2020-01-09 13:52:12karczexcreate