All,

I'm trying to debug a GC-related problem for FXRuby. The symptom is that
one of the Ruby Data objects created by FXRuby is getting its "mark"
function called after it should no longer be reachable. That is to say,
unless I misunderstand Ruby's scoping rules, no other object should be
able to reach "see" this object and so its mark function shouldn't be
called.

This is a big problem because the C++ object that this Data object
refers to has in fact been destroyed by this point, and so the Ruby Data
object has a "dangling" pointer. The code inside the mark function for
this class assumes that the object hasn't been destroyed yet; after all,
Ruby thinks it's still alive and so it must be OK. And we all know how
ugly things can get when you try to dereference a dangling pointer.

So I guess I have a few questions at this point:

  1. Am I correct that during the garbage collector's "mark" phase, only
     those objects that are truly reachable from some other object should
     be having their "mark" function called?

  2. If so, is there some way to figure out the "reachability" path that
     leads to this object (which by my inspection shouldn't be
     reachable)? I was looking at ObjectSpace.each_object() but this
     visits every object still on the heap, including those that may no
     longer be reachable but have not yet been garbage-collected.

If I am wrong about the garbage collector's mark phase and it in fact 
visits *all* of the objects still alive on the heap (including those 
that are no longer reachable) I guess I need to know that too. Although 
that makes things a bit more challenging ;)

Thanks in advance for any advice,

Lyle