Question about finalizers for extension objects

I’m trying to debug an FXRuby-related problem that only occurs when the
Ruby interpreter is shutting down.

During this process, the function rb_gc_call_finalizer_at_exit() loops
over all of the data objects and, for each of those Ruby instances,
calls the associated C/C++ object’s freefunc (or plain old free() if no
freefunc was defined).

My question is: at the time that this is going on, should I assume that
the Ruby instances themselves are basically garbage at this point (even
if their freefunc() hasn’t been called yet)? In other words if I’m in
the freefunc for C++ object A, can I call instance methods on some other
Ruby object?

if their freefunc() hasn't been called yet)? In other words if I'm in
the freefunc for C++ object A, can I call instance methods on some other
Ruby object?

No, you can't predict in which order will run the finalizer (except if you
do some stupid things, like in some of my extensions ...).

This mean, in your case, that you can call instance methods on object
gc'ed and ruby will crash

Guy Decoux