From: Paul Brannan Date: 2002-10-22T03:54:24+09:00 Subject: rb_gc_register_address problem We ran into a problem today with the garbage collector (caused by our own bug). We had a function that did something like this: std::vector foo; void func(int argc, VALUE * argv, VALUE self) { foo.push_back(STR2CSTR(argv[0])); rb_global_variable(&argv[0]); } This is a bug, because once the function returns, argv[0] is invalid, and global_List contains an invalid VALUE* that may or may not point to the VALUE we want to keep global. When the GC tries to mark this VALUE*, it ends up marking an invalid object. So my question is: why does rb_gc_register_address() store VALUE*'s instead of VALUE's? I suppose that if it stored a VALUE, then it would be possible to register an object as a global but not keep a reference to that object; this may not be desirable. In our case, though, we just wanted the string to remain valid. If I do have a bug like this in the future, what techniques can I use to track it down? Paul