Fatal Python error: deallocating None

hi,

i had various fatal crashes of my application with a

 Fatal Python error: deallocating None

this problem is very hard to detect and might not influence your application at all, so do not worry.

still this is a very in-depth problem and if it happens and you use Panda3D 1.3.2 and the getPythonTag call you might have problems.

i looked into the cause of this problem for Panda3D-1.3.2

Panda3D-1.3.2:

panda/src/pgraph/pandaNode.cxx: PandaNode::get_python_tag: there is a missing Py_INCREF(Py_None) which is probably causing this problem (at least in my application as far as i can tell - really hard to debug this bugger).

in Panda3D-CVS this has been fixed.

i did not look further in the Panda3D-1.3.2 source tree, but i looked through Panda3D-CVS to see if there are any more of possible problems.

i assume David :slight_smile: can judge my findings better.

***** dbClass.cxx

DCClass:get_class_def
#429 return Py_None
without a PY_INCREF(Py_None)

DCClass::get_owner_class_de
#477 return Py_None
without a PY_INCREF(Py_None)

***** dcPacker.cxx

DCPacker::unpack_object
#804 object = Py_None
later object is returned but in the case of Py_None, Py_None needs to be PY_INCREF’d right?

***** interfaceMakerPythonNative.cxx

InterfaceMakerPythonNative::write_module_class (i assume this file influences all *_igate.cxx files)

#1274 when creating a func call with 2 arguments, Py_None is used 2 times (not sure if a PY_INCREF is necessary)

#1287 same for a func call with 1 argument

hth,
kaweh

Excellent detective work! I have fixed the problems you have noted in dcClass and dcPacker. The ones in interfaceMakerPythonNative are actually OK, since those lines are generating calls into a Python function, rather than returning from a function; so it does not require upping the reference count.

David