Battle of the garbage collectors, or ARGGHHHHHH!!!!

Jon Ribbens jon+usenet at unequivocal.eu
Mon Apr 24 20:54:32 EDT 2017


On 2017-04-24, CFK <cfkaran2 at gmail.com> wrote:
> Long version: I'm trying to write bindings for python via ctypes to control
> a library written in C that uses the bdwgc garbage collector (
> http://www.hboehm.info/gc/).  The bindings mostly work, except for when
> either bdwgc or python's garbage collector decide to get into an argument
> over what is garbage and what isn't, in which case I get a segfault because
> one or the other collector has already reaped the memory.

Make your Python C objects contain a pointer to a
GC_MALLOC_UNCOLLECTABLE block that contains a pointer to the
bwdgc object it's an interface to? And GC_FREE it in tp_dealloc?
Then bwdgc won't free any C memory that Python is referencing.


More information about the Python-list mailing list