This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
I just had what might be a similar experience with uncollected garbage. I have a C library that returns void*'s to its own struct on open, and then one can manipulate them. The library has callbacks; you give it a function pointer and a void*; it calls your function with the void* as argument, but the C library never looks at it the void* cookie. On wrapping this for guile, I made a smob that has a pointer to the C library structure, and some SCM procedure objects. The C callback function in the guile wrapper is passed to the C open call, and just calls the SCM callback. It uses the void* callback argument to find the smob object when the callback happens, so it can call the right SCM callback. So (simplifying a lot), the smob looks like: LibraryType foo; (void* from our point of view) SCM data_callback; The library looks like blahblahblah; /* actual library data */ void (*callback)(); /* function pointer */ void *callback_cookie; /* happens to be the SCM value for the smob */ I think that it might have been the case that the conservative scan came across the smob pointer in the library struct and marked the smob, but I'm not 100% sure. So, upon closing one of these objects, I changed the underlying library to clear the cookie value. This would only work if the object is closed, if my theory is right. After doing this, unreferenced closed objects seem to get gc'd (modulo an extra cons to the repl), but unreferenced open objects don't seem to get gc'd. I didn't think the gc scanned malloc'd area, but I'm not really clear on things like this. I thought this potential pitfall might be informative to someone. Greg Troxel <gdt@ir.bbn.com>