[Pyrex] Tricky bug while unloading modules

Gustavo Sverzut Barbieri barbieri at gmail.com
Sat Nov 17 03:07:03 CET 2007


On Nov 16, 2007 10:20 PM, Robert Bradshaw <robertwb at math.washington.edu> wrote:
>
> On Nov 16, 2007, at 5:05 PM, Greg Ewing wrote:
>
> > Gustavo Sverzut Barbieri wrote:
> >
> >> (indirectly, in my case it's a string that cython
> >> caches as a global object)
> >
> > What exactly is this string, and how does it get cached?
>
> Some clarification here: I think this is a cython only bug. I would
> guess (based on the comments so far) that the string getting cached
> is an interned string in the module. As far as I can tell, cython
> modules are never actually unloaded when Python exits, and so
> interned strings and global variables are never freed. To facilitate
> memory debugging, we deallocate these things when Python exits in a
> module-level cleanup() function. If modules are deallocated in the
> wrong order, bad things can happen.

That is exactly the problem.


> The fix is to either register a function to del the problem manually
> with atexit, or to compile the files with a cleanup level of 0 (in
> Options.py).

Ok, doing that for now.

-- 
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: barbieri at gmail.com
   MSN: barbieri at gmail.com
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010



More information about the Pyrex mailing list