Segfault when using own C-written module and exiting python
Dear List,
I am having trouble with some of the use-cases for a C-written module of my own (if curious, I am working on Python-R interface... this is open source so I can provide the whole source if needed).
Everything is working just fine and as expected... until the python process exits.
When running my test script through gdb and with the '-v' flag for Python, it ends with
# cleanup __main__
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7dde8c0 (LWP 19670)] 0x080f3d08 in PyObject_GC_UnTrack ()
I have looked for information on the internet... but have not found much. Would this kind of error be familiar to anyone ?
Thanks,
Laurent
On 2008-06-06 12:31, Laurent Gautier wrote:
Dear List,
I am having trouble with some of the use-cases for a C-written module of my own (if curious, I am working on Python-R interface... this is open source so I can provide the whole source if needed).
Everything is working just fine and as expected... until the python process exits.
When running my test script through gdb and with the '-v' flag for Python, it ends with
# cleanup __main__
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7dde8c0 (LWP 19670)] 0x080f3d08 in PyObject_GC_UnTrack ()
I have looked for information on the internet... but have not found much. Would this kind of error be familiar to anyone ?
I've never seen this particular error before, but it's likely that you have a ref count bug somewhere in your code.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Jun 06 2008)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2008-07-07: EuroPython 2008, Vilnius, Lithuania 30 days to go
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
Hi,
M.-A. Lemburg wrote:
On 2008-06-06 12:31, Laurent Gautier wrote:
I am having trouble with some of the use-cases for a C-written module of my own (if curious, I am working on Python-R interface... this is open source so I can provide the whole source if needed).
I've never seen this particular error before, but it's likely that you have a ref count bug somewhere in your code.
If the existing code base isn't too large yet, consider switching to Cython instead of C.
Stefan
I have probably found the problem. I report it here in case someone has the same issue later.
In my tp_new I had:
PyObject_New(MyType, type);
(and it was working just fine until I started with subclasses)
while it seems that it should have been:
type->tp_alloc(type, 0);
L.
2008/6/6 Laurent Gautier lgautier@gmail.com:
Dear List,
I am having trouble with some of the use-cases for a C-written module of my own (if curious, I am working on Python-R interface... this is open source so I can provide the whole source if needed).
Everything is working just fine and as expected... until the python process exits.
When running my test script through gdb and with the '-v' flag for Python, it ends with
# cleanup __main__
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7dde8c0 (LWP 19670)] 0x080f3d08 in PyObject_GC_UnTrack ()
I have looked for information on the internet... but have not found much. Would this kind of error be familiar to anyone ?
Thanks,
Laurent
On Fri, Jun 6, 2008 at 1:40 PM, Laurent Gautier lgautier@gmail.com wrote:
I have probably found the problem. I report it here in case someone has the same issue later.
In my tp_new I had:
PyObject_New(MyType, type);
(and it was working just fine until I started with subclasses)
while it seems that it should have been:
type->tp_alloc(type, 0);
Do you have Py_TPFLAGS_HAVE_GC set? That'd require you to use PyObject_GC_New, which'd allocate extra space for the tracking flag, and the absence of which would explain the crash.
-- Adam Olsen, aka Rhamphoryncus
I stumbled upon some documentation about that (it had to do with circular references, AFAIR)... and I don't think that I have that flag set. I only have: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE
2008/6/7 Adam Olsen rhamph@gmail.com:
On Fri, Jun 6, 2008 at 1:40 PM, Laurent Gautier lgautier@gmail.com wrote:
I have probably found the problem. I report it here in case someone has the same issue later.
In my tp_new I had:
PyObject_New(MyType, type);
(and it was working just fine until I started with subclasses)
while it seems that it should have been:
type->tp_alloc(type, 0);
Do you have Py_TPFLAGS_HAVE_GC set? That'd require you to use PyObject_GC_New, which'd allocate extra space for the tracking flag, and the absence of which would explain the crash.
-- Adam Olsen, aka Rhamphoryncus
participants (4)
-
Adam Olsen
-
Laurent Gautier
-
M.-A. Lemburg
-
Stefan Behnel