[Pyrex] __Pyx_GetStarArgs can cause segfault when called by __new__

Jiba jiba at tuxfamily.org
Fri Jan 16 00:23:37 CET 2004


Hi,

I'm experimenting segfault in Pyrex object creation. It seems that, if i
define a __new__ method as following :

class CoordSyst:
  cdef object obj
  def __new__(self, *args, **kargs):
    [...]

the generated C code calls __Pyx_GetStarArgs, which creates dict
objects.
Then the dict object creation can call a GC collection, and the
CoordSyst object is not yet finalized (e.g. the obj attribute have not
been to None yet, and probably points nowhere, thus segfaulting).

is there a solution ? I guess __Pyx_GetStarArgs should be rewritten to
avoid GC collection in it, but i'm not sure whether is possible or not ?


Here is the GDB backtrace i got (Face object inherits from CoordSyst) :

#0  visit_decref (op=0x0, data=0x0) at Modules/gcmodule.c:225
#1  0x40376057 in __pyx_tp_traverse_9soyapyrex_Face (o=0x825e87c,
v=0x80ed590 <visit_decref>, a=0x0) at soyapyrex.c:28059
#2  0x080ee1b2 in collect (generation=0) at Modules/gcmodule.c:250
#3  0x080ed916 in _PyObject_GC_New (tp=0x8126ee0) at
Modules/gcmodule.c:788
#4  0x0807747a in PyDict_New () at Objects/dictobject.c:167
#5  0x40377898 in __Pyx_GetStarArgs (args=0xbfffe14c, kwds=0xbfffe150,
kwd_list=0x403beb84, nargs=0, args2=0xbfffe154, kwds2=0xbfffe158) at
soyapyrex.c:30269
#6  0x4036c79e in __pyx_tp_new_9soyapyrex_CoordSyst (t=0x403bc260,
a=0x402fe2ac, k=0x0) at soyapyrex.c:5775
#7  0x40375f2a in __pyx_tp_new_9soyapyrex_Face (t=0x403bc260,
a=0x402fe2ac, k=0x0) at soyapyrex.c:28038
#8  0x080894b6 in type_call (type=0x403bc260, args=0x402fe2ac, kwds=0x0)
at Objects/typeobject.c:417
...

Jiba




More information about the Pyrex mailing list