On 2017-04-24, CFK <cfkar...@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.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to