From: "Iñaki Baz Castillo" Date: 2011-02-06T08:02:39+09:00 Subject: C extension: How to check if a VALUE is still alive (not being GC'ed)? Hi, I'm coding an async DNS resolver for EventMachine based on udns (a C library). In the Ruby C extension, when submitting a DNS query I pass the current object (VALUE pointer) as an argument of the DNS query C function. Later on, when the DNS server replies, EventMachine (which watches on the UDP socket of udns) invokes the C callback function belonging to such query, and that callback includes the given VALUE as one of its arguments. So I invoke a Ruby method for such VALUE (rb_funcall). The problem is that the VALUE could be GC'ed (or being marked for so) if the programmer assigns it to "nil" before the callback is executed, so we get a coredump. So when the callback is executed I need to check that the given VALUE is still alive (not GC'ed neither marked for being GC'ed). How can I inspect that? (I mean in C). Thanks a lot. -- Iñaki Baz Castillo