[Pyrex] __Pyx_GetStarArgs can cause segfault when called by
__new__
Jiba
jiba at tuxfamily.org
Fri Jan 16 19:54:40 CET 2004
On Thu, 15 Jan 2004 21:31:53 -0800
Paul Prescod <paul at prescod.net> wrote:
> Jiba wrote:
> > 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):
> > [...]
>
> I have trouble even compiling your code.
> If I put a "cdef" before "class" then it builds and runs fine.
yes you are right !
actually the few lines above are not really a fully working example, but
are just here for illustration...
The bug occurs at random, since all dict creations do not imply a GC
collection.
Here is a small example that DOES segfault, with an artificial call to
gc.collect() :
(Notice that if you define the "obj" attribute in class C instead of D,
it does not segfault. It seems that when C.__new__ is executed, C
attributes are initialized to None, but D ones are not initialized yet)
cdef class C:
def __new__(self, *arg, **kargs):
import gc
gc.collect()
cdef class D(C):
cdef object obj
D()
Jiba
More information about the Pyrex
mailing list