I'm not yet a 100% sure what is happening in my application, but I'm 
embedding Julia and using cfunction() to generate C-callable functions that 
at a later time invoke the registered julia code. I use a fairly standard 
pattern I think, of passing a pointer to a julia object that is retain in C 
and later passed down to the callback created by cfunction, and from there 
resolved to the original real Julia reference type, invoking a closure. The 
closure itself is retained in some global state to prevent garbage 
collection. What appears to be happening however, is the code at the 
landing site for the cfunction returned pointer is at some point garbage 
collection (or at least corrupted), as my program, after a while of 
running, will segfault upon invoking the callback (after many previously 
successful callbacks). It segfaults because it hits invalid code, and it's 
not that some state is missing when running the code.

Is this to be be expected, and what's the right way to ensure the code 
isn't GC'd?

Reply via email to