Incorrect GC cleanup order with C extension classes
I have two classes as C extensions. One (the child) holds a reference to the other (parent). The child references parent via rb_ivar_set(). Further, child also registers mark function to mark parent. Despite this, parent is still GC'd before child on process exit. Thus, when dhild's destructor is called (next), its parent ref points to invalid memory, causing potential segfault.
Working example code is here:
This also occurs if I set child to nil and then call GC.start().
Behavior is same on 1.9.1 through ruby_1_9_3@35295.
My understanding of proper behavior is that child's reference to parent (and/or it's mark function) should keep parent destructor from being called first. Neither of these seem to work.