[C++-sig] Extending python and using debug interpreter on Linux

Brian O'Kennedy brian.o'kennedy at vicon.com
Tue Apr 21 17:12:08 CEST 2009


Hi, 

I've built a local copy of Python with PY_DEBUG enabled and tried import
a simple module which only defs a single c++ function returning a
std::string.  My test involves importing the module, and then quitting
the interpreter; I'm not trying to call anything in the module. 

This works as expected in Release mode on linux (as well as working
correctly on Windows for Release and Debug(with PY_DEBUG).  

However, on Linux using the debug interpreter I get a "Fatal Python
error: UNREF invalid object" with the callstack as follows:

#0  0xb7f3e430 in __kernel_vsyscall ()
#1  0xb7bf48a0 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7bf6268 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7ea2837 in Py_FatalError (msg=0xb7ed7ed4 "UNREF invalid object")
at Python/pythonrun.c:1561
#4  0xb7dfe3d2 in _Py_ForgetReference (op=0xb7b87754) at
Objects/object.c:1918
#5  0xb7dfe431 in _Py_Dealloc (op=0xb7b87754) at Objects/object.c:1937
#6  0xb7df2b12 in insertdict (mp=0xb7b89714, key=0xb7b7a208,
hash=1901421549,   value=0xb7efa8a8) at Objects/dictobject.c:420
#7  0xb7df33e0 in PyDict_SetItem (op=0xb7b89714, key=0xb7b7a208,
value=0xb7efa8a8) at Objects/dictobject.c:645
#8  0xb7e8f4b7 in PyImport_Cleanup () at Python/import.c:475
#9  0xb7e9f44c in Py_Finalize () at Python/pythonrun.c:399
#10 0xb7ea2a1e in Py_Exit (sts=0) at Python/pythonrun.c:1618
#11 0xb7ea0e0a in handle_system_exit () at Python/pythonrun.c:1054
#12 0xb7ea0e3b in PyErr_PrintEx (set_sys_last_vars=1)   at
Python/pythonrun.c:1064
#13 0xb7ea0af1 in PyErr_Print () at Python/pythonrun.c:978
#14 0xb7ea00ca in PyRun_InteractiveOneFlags (fp=0xb7d23420,
filename=0xb7eeaf07 "<stdin>", flags=0xbf83f4ac) at
Python/pythonrun.c:795
#15 0xb7e9fcda in PyRun_InteractiveLoopFlags (fp=0xb7d23420,
filename=0xb7eeaf07 "<stdin>", flags=0xbf83f4ac) at
Python/pythonrun.c:723
#16 0xb7e9fb06 in PyRun_AnyFileExFlags (fp=0xb7d23420,
filename=0xb7eeaf07 "<stdin>", closeit=0, flags=0xbf83f4ac)   at
Python/pythonrun.c:692
#17 0xb7eb0ade in Py_Main (argc=1, argv=0xbf83f5b4) at
Modules/main.c:532
#18 0x080485e2 in main (argc=Cannot access memory at address 0x3392

Anyone have any ideas what is going wrong?  I'm aware that there are
issues with Boost Python and Py_Finalize, but is that what is causing
this problem? 

Using Boost 1.38.0 and Python 2.5.4, both built from source on both
Linux Ubuntu gcc42 and Windows Vista using VS2005. 

Thanks, 
 Brian




________________________________________________________________________
This e-mail, and any attachment, is confidential. If you have received it in error, do not use or disclose the information in any way, notify me immediately, and please delete it from your system.
________________________________________________________________________


More information about the Cplusplus-sig mailing list