ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Ryan Pavlik <rpav@users.sourceforge.net>
To: ruby-core@ruby-lang.org, ruby-talk@ruby-lang.org
Subject: _id2ref bug?
Date: Fri, 15 Aug 2003 01:45:02 +0900	[thread overview]
Message-ID: <20030814094459.1c21fa19.rpav@users.sf.net> (raw)

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

             reply	other threads:[~2003-08-14 16:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-14 16:45 Ryan Pavlik [this message]
2003-08-14 16:57 ` _id2ref bug? Yukihiro Matsumoto
2003-08-14 17:01   ` ts
2003-08-14 17:08     ` Yukihiro Matsumoto
2003-08-14 17:44       ` Ryan Pavlik
2003-08-14 17:46   ` Ryan Pavlik
2003-08-15  0:10     ` Yukihiro Matsumoto
2003-08-14 18:09   ` _id2ref bug? (REPRODUCED, short) Ryan Pavlik
2003-08-15  0:21     ` Yukihiro Matsumoto
2003-08-15  2:37       ` _id2ref bug? (another break) Ryan Pavlik
2003-08-15  3:35         ` nobu.nokada
2003-08-15  4:19           ` Ryan Pavlik
2003-08-15  4:48             ` Ruby Tk on Mac OS X Mark Wilson
2003-08-15  5:22               ` nobu.nokada
2003-08-15  6:10                 ` Mark Wilson
2003-08-15  7:14                   ` nobu.nokada
2003-08-15 10:17           ` _id2ref bug? (another break) ts
2003-08-15 17:42             ` Ryan Pavlik
2003-08-16  9:35               ` ts
2003-08-16 11:02                 ` nobu.nokada
2003-08-16 11:08                   ` ts
2003-08-16 12:54                     ` nobu.nokada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030814094459.1c21fa19.rpav@users.sf.net \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-talk@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).