From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (8.12.3+3.5Wbeta/8.12.6/Debian-8) with ESMTP id h7GAuSGc004502; Sat, 16 Aug 2003 19:56:28 +0900 Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with SMTP id 6807657C2; Sat, 16 Aug 2003 20:02:18 +0900 (JST) Received: from helium.ruby-lang.org (helium.ruby-lang.org [210.251.121.214]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 0951C63003F; Sat, 16 Aug 2003 20:02:16 +0900 (JST) Received: from helium.ruby-lang.org (localhost [127.0.0.1]) by helium.ruby-lang.org (Postfix) with ESMTP id BC436AAB; Sat, 16 Aug 2003 20:02:15 +0900 (JST) Received: from sharui.nakada.kanuma.tochigi.jp (202-213-084-079.users.bc9.ne.jp [202.213.84.79]) by helium.ruby-lang.org (Postfix) with ESMTP id EF6D877A for ; Sat, 16 Aug 2003 20:02:14 +0900 (JST) Received: from sharui.nakada.kanuma.tochigi.jp (localhost [127.0.0.1]) by sharui.nakada.kanuma.tochigi.jp (8.12.8/8.12.8) with ESMTP id h7GB2DPL018190; Sat, 16 Aug 2003 20:02:14 +0900 Date: Sat, 16 Aug 2003 20:02:15 +0900 Posted: Sat, 16 Aug 2003 20:02:13 +0900 From: nobu.nokada@softhome.net Reply-To: ruby-core@ruby-lang.org Subject: Re: _id2ref bug? (another break) To: ruby-core@ruby-lang.org Message-Id: <200308161102.h7GB2DPL018190@sharui.nakada.kanuma.tochigi.jp> In-Reply-To: <200308160935.h7G9ZPe22575@moulon.inra.fr> References: <20030814094459.1c21fa19.rpav@users.sf.net> <1060880235.666474.27392.nullmailer@picachu.netlab.jp> <20030814110915.31f8f04d.rpav@users.sf.net> <1060906889.631559.29136.nullmailer@picachu.netlab.jp> <20030814193740.3a5948e1.rpav@users.sf.net> <200308150335.h7F3ZVPL019823@sharui.nakada.kanuma.tochigi.jp> <200308151017.h7FAH8a15508@moulon.inra.fr> <20030815104223.7a644dda.rpav@users.sf.net> <200308160935.h7G9ZPe22575@moulon.inra.fr> X-ML-Name: ruby-core X-Mail-Count: 01428 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-core-ctl@ruby-lang.org; help= User-Agent: Wanderlust/2.10.0 (Venus) SEMI/1.14.4 (Hosorogi) FLIM/1.14.4 (=?ISO-8859-4?Q?Kashiharajing=FE-mae?=) APEL/10.4 MULE XEmacs/21.4 (patch 12) (Portable Code) (i386-redhat-linux) Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-Id: ruby-core.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: X-Virus-Scanned: by AMaViS perl-10 Hi, At Sat, 16 Aug 2003 18:35:30 +0900, ts wrote: > R> This isn't so strange. If T_NODE are kept in the same pool as > R> everything else, then it's entirely possible to get one by accident, > > and this means that you have a bug in your source. You can retrieve a > valid object, which was not the original object : difficult to trust your > code in this case. Ryan is correct. $ ruby -e 'x = ""; eval("x"); y = ""; x = [x.id, y.id]; x.min.step(x.max, 10){|i| p ObjectSpace._id2ref(i)}' "" -e:1: [BUG] Segmentation fault ruby 1.8.0 (2003-08-15) [i686-linux] Aborted (core dumped) And I guess this would make better message than [ruby-core:01417]. Index: gc.c =================================================================== RCS file: /cvs/ruby/src/ruby/gc.c,v retrieving revision 1.155 diff -u -2 -p -r1.155 gc.c --- gc.c 14 Aug 2003 17:19:23 -0000 1.155 +++ gc.c 16 Aug 2003 10:58:42 -0000 @@ -1637,8 +1637,8 @@ id2ref(obj, id) ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */ - if (!is_pointer_to_heap((void *)ptr)) { + if (!is_pointer_to_heap((void *)ptr) || BUILTIN_TYPE(ptr) >= T_BLKTAG) { rb_raise(rb_eRangeError, "0x%lx is not id value", p0); } - if (RBASIC(ptr)->klass == 0) { + if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) { rb_raise(rb_eRangeError, "0x%lx is recycled object", p0); } -- Nobu Nakada