[#1378] differences between Module and Class ? — Mathieu Bouchard <matju@...>

25 messages 2003/08/11
[#1387] Re: differences between Module and Class ? — matz@... (Yukihiro Matsumoto) 2003/08/12

Hi,

[#1442] Re: differences between Module and Class ? — Mathieu Bouchard <matju@...> 2003/08/21

[#1406] _id2ref bug? — Ryan Pavlik <rpav@...>

While debugging some caching code, I've come across a segfault related

22 messages 2003/08/14
[#1407] Re: _id2ref bug? — matz@... (Yukihiro Matsumoto) 2003/08/14

Hi,

[#1413] Re: _id2ref bug? (REPRODUCED, short) — Ryan Pavlik <rpav@...> 2003/08/14

On Fri, 15 Aug 2003 01:57:18 +0900

_id2ref bug?

From: Ryan Pavlik <rpav@...>
Date: 2003-08-14 16:45:02 UTC
List: ruby-core #1406
While debugging some caching code, I've come across a segfault related
to ObjectSpace::_id2ref.  Apparently it's returning illegal objects:

  Remote Exception: NotImplementedError:
  /usr/local/encap/mephle-0.8.0/share/mephle/Driver/Storage_cache.rb:49:in
  `cache': method `_oid' called on terminated object (0x4043a568)

The code up to this point:

  ...
    o = ObjectSpace::_id2ref(id)
    cache(o)
  rescue RangeError ...
  ...

def cache(object)
  oid = object._oid        # line 49
  ...
end


It seems that somehow, it's returning a bad object, or the object is
getting collected after the fact, or something.   I'm checking for
RangeError, and this isn't getting raised.  I tried GC.start
and Thread.critical=true, around this block.  Same deal.

Sometimes it outright segfaults.

So far, I haven't been able to reproduce this with a tiny script.
However, I have been able to confirm that it is getting collected, by
checking the __id__'s via a finalizer.  So _id2ref is somehow returning
a collected object.

Not using _id2ref isn't really an option; it's critical to maintaining
integrity, so I can't really get around using it.

-- 
Ryan Pavlik <rpav@users.sf.net>

"I distinctly remember dancing on your grave." - 8BT

In This Thread

Prev Next