[Pyrex] Problems with pyrex and glib

Drirr miston.drirr at gmail.com
Sat Jan 7 20:35:48 CET 2006


Hello,

I'm writing a module for python using pyrex and C, and I need to link 
against glib. However after a program which imports my module finishes, 
I get a error from glib about double frees, even if I don't use any C.

For example:

----- Pyrex file: (realbase.pyx)

cdef class Container:
    def __init__(self):
        print "Init"

    def __dealloc__(self):
        print "Dealloc"

global_context = Container()

----- Test file: (test.py)

import realbased

print "DONE"

----- What I used to build the module:
python /usr/bin/pyrexc realbase.pyx
gcc -fPIC -Wall -g `pkg-config --cflags glib-2.0` -fPIC 
-I/usr/include/python2.4/  -c realbase.c -o realbase.o
gcc realbase.o -g `pkg-config --libs glib-2.0` -shared  -o realbase.so

----- The output from running test.py
Init
DONE
*** glibc detected *** double free or corruption (!prev): 0x08058630 ***
Aborted

-----

If I comment out the __dealloc__ method, everything runs fine, but 
Container will be a wrapper around a C structure, so I need that method 
to free it.

Does anyone know what can be the problem here?

Pyrex version: 0.9.3
Python version: 2.4.2
Glib version: 2.6.5
gcc version: 3.3.6



Thank you
Drirr



More information about the Pyrex mailing list