[Pyrex] Re: Problems with pyrex and glib
Toby
tobia.conforto at linux.it
Sun Jan 8 11:52:29 CET 2006
Drirr wrote:
> *** glibc detected *** double free or corruption (!prev): 0x08058630 ***
> Aborted
It's not related to glib. It happens in a standalone build too:
pyrexc realbase.pyx
gcc -fPIC -I/usr/include/python2.4/ -c realbase.c -o realbase.o
gcc realbase.o -shared -o realbase.so
The culprit is calling Python stuff from __dealloc__. Quoting Greg:
You need to be careful what you do in a __dealloc__ method.
[...] you should avoid invoking any Python operations [...]
It's best if you stick to just deallocating C data.
In fact, taking Python operations (such as print and the chain of stuff
called from print) out of __dealloc__ seems to solve the problem:
cdef extern int puts(char* s)
cdef class Container:
def __init__(self):
print "Init"
def __dealloc__(self):
puts("Dealloc")
global_context = Container()
Toby
--
Pascal is for building pyramids—imposing, breathtaking structures
built by armies pushing heavy blocks into place.
Lisp is for building organisms . . . —Alan Perlis
More information about the Pyrex
mailing list