[Pyrex] Unlucky fellow needs help (pyrex crashes)

Lenard Lindstrom len-l at telus.net
Fri Feb 24 02:13:25 CET 2006


On 23 Feb 2006 at 17:25, Greg Ewing wrote:

> Helmut Jarausch wrote:
> 
> > cdef class ITNO    # forward declaration
> > 
> > cdef class ITNO_List(ITNO):
> >   cdef int cnt
> >   cdef int From
> >   cdef int To
> 
> This is an error, since I never intended to support
> using a class as a base class prior to its definition.
> It's a bug that Pyrex crashes instead of reporting the
> error, though.
> 
> > Variant II is accepted by pyrexc but
> > gives a segment fault while running the loop
> > 
> > cdef class ITNO             # forward declaration
> > cdef class ITNO_List(ITNO)  # forward declaration
> 
> I'm not sure whether this should be allowed or not.
> I'll look into these.
> 
> Thanks,
> 
The problem is that the ITNO  __new__ takes no arguments while the 
ITNO_List  __new__ takes two. When creating a new ITNO_List instance  
the INTO __new__ function is called with the wrong number of 
arguments and raises an exception.

The segment fault is because Pyrex is not checking if ITNO.__new__ 
has raised an exception so calls INTO_List.__new__ with an invalid 
object. Pyrex generated tp_new slot functions do not test if the 
pointer to the newly allocated object is NULL.

Lenard Lindstrom
<len-l at telus.net>




More information about the Pyrex mailing list