On Thu, Mar 19, 2015 at 12:21:47PM -0700, Christopher Collins wrote: > The way I understood it, the returned "mystruct" instance would never get > garbage collected until I explicitly call CHICKEN_delete_gc_root(). I never > actually delete the root (I set a breakpoint on CHICKEN_delete_gc_root in gdb, > just to be sure), but the object gets garbage collected anyway. The next time > I try to pass the instance of mystruct to a scheme procedure, the procedure > fails because the argument is not of the expected type (when I print the > argument, I see " #<invalid forwarded object>").
Hello Christopher, How are you accessing the object? If it's from C, you need to use GC_root_ref to obtain a fresh reference to the object; you can't use a stale reference to the object you saved in the GC root. > I must be confused about how gc roots work. Am I doing anything that is > obviously wrong? I can try to post some real code if that would help. It would certainly help if you posted a minimal example of the failing situation. I don't immediately saw anything wrong with the bit you posted, but it only showed how you saved the object, not how the rest of the code uses it. Also, please be aware of http://bugs.call-cc.org/ticket/1173; you'll only run into that if you enable symbol GC though, which happens when you pass -:w to a CHICKEN program or set C_enable_gcweak to nonzero. Cheers, Peter
signature.asc
Description: Digital signature
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users