Issue #5350 has been reported by Makoto Kishimoto.

----------------------------------------
Bug #5350: WeakRef で謎の NoMethodError
http://redmine.ruby-lang.org/issues/5350

Author: Makoto Kishimoto
Status: Open
Priority: Low
Assignee: 
Category: 
Target version: 1.9.x
ruby -v: ruby 1.9.4dev (2011-07-18 trunk 32577) [x86_64-freebsd8.2]


添付のようなスクリプトを r18232 以降の ruby 1.9 で走らせると、以下のように
RefError ではなく NoMethodError が上がってくる、ということが起きます。
( value メソッドを呼ぶ直前に weakref_alive? を呼んでみると true が
返っています )

r18220 以前では正常に動きます( r18221 〜 r18231 では core を吐きます)。

ruby 1.9.0 (2008-07-27 revision 0) [x86_64-freebsd8.2]
../weakref_bug.rb:20:in `part': undefined method `value' for [17188951200]:WeakRef (NoMethodError)
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:38:in `block in <main>'
        from ../weakref_bug.rb:36:in `each'
        from ../weakref_bug.rb:36:in `<main>'

ruby 1.9.4dev (2011-07-18 trunk 32577) [x86_64-freebsd8.2]
../weakref_bug.rb:20:in `part': undefined method `value' for "../weakref_bug.rb:36:in `<main>'":WeakRef (NoMethodError)
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:29:in `block in part'
        from ../weakref_bug.rb:27:in `downto'
        from ../weakref_bug.rb:27:in `each'
        from ../weakref_bug.rb:27:in `part'
        from ../weakref_bug.rb:38:in `block in <main>'
        from ../weakref_bug.rb:36:in `each'
        from ../weakref_bug.rb:36:in `<main>'

/home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/weakref.rb:58: [BUG] gc_sweep(): unknown data type 0x0(0x801019088)
ruby 1.9.0 (2008-07-25 revision 0) [x86_64-freebsd8.2]

-- control frame ----------
c:0023 p:---- s:0072 b:0072 l:000071 d:000071 CFUNC  :_id2ref
c:0022 p:0069 s:0068 b:0068 l:000067 d:000067 METHOD /home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/weakref.rb:58
c:0021 p:0007 s:0065 b:0065 l:000064 d:000064 METHOD /home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/delegate.rb:139
c:0020 p:---- s:0058 b:0058 l:000057 d:000057 FINISH :eql?
c:0019 p:0041 s:0056 b:0055 l:000054 d:000054 METHOD ../weakref_bug.rb:20
c:0018 p:0032 s:0048 b:0047 l:000036 d:000046 BLOCK  ../weakref_bug.rb:29
c:0017 p:---- s:0046 b:0046 l:000045 d:000045 FINISH :==
c:0016 p:---- s:0044 b:0044 l:000039 d:000043 IFUNC  :==
c:0015 p:---- s:0042 b:0042 l:000041 d:000041 CFUNC  :downto
c:0014 p:---- s:0040 b:0040 l:000039 d:000039 CFUNC  :each
c:0013 p:0074 s:0037 b:0037 l:000036 d:000036 METHOD ../weakref_bug.rb:27
c:0012 p:0032 s:0030 b:0029 l:000018 d:000028 BLOCK  ../weakref_bug.rb:29
c:0011 p:---- s:0028 b:0028 l:000027 d:000027 FINISH :==
c:0010 p:---- s:0026 b:0026 l:000021 d:000025 IFUNC  :==
c:0009 p:---- s:0024 b:0024 l:000023 d:000023 CFUNC  :downto
c:0008 p:---- s:0022 b:0022 l:000021 d:000021 CFUNC  :each
c:0007 p:0074 s:0019 b:0019 l:000018 d:000018 METHOD ../weakref_bug.rb:27
c:0006 p:0013 s:0012 b:0012 l:000005 d:000011 BLOCK  ../weakref_bug.rb:38
c:0005 p:---- s:0011 b:0011 l:000010 d:000010 FINISH :method_added
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC  :each
c:0003 p:0047 s:0006 b:0006 l:000005 d:000005 TOP    ../weakref_bug.rb:36
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :private_class_method
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP
---------------------------
/home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/weakref.rb:58: [BUG] object allocation during garbage collection phase
ruby 1.9.0 (2008-07-25 revision 0) [x86_64-freebsd8.2]

-- control frame ----------
c:0023 p:---- s:0072 b:0072 l:000071 d:000071 CFUNC  :_id2ref
(上と同じなので省略)
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP
---------------------------
DBG> : "/home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/weakref.rb:58:in `_id2ref'"
DBG> : "/home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/weakref.rb:58:in `__getobj__'"
DBG> : "/home/ksmakoto/ruby-working/ruby-weakref/lib/ruby/1.9.0/delegate.rb:139:in `method_missing'"
DBG> : "../weakref_bug.rb:20:in `part'"
DBG> : "../weakref_bug.rb:29:in `block in part'"
DBG> : "../weakref_bug.rb:27:in `downto'"
DBG> : "../weakref_bug.rb:27:in `each'"
DBG> : "../weakref_bug.rb:27:in `part'"
DBG> : "../weakref_bug.rb:29:in `block in part'"
DBG> : "../weakref_bug.rb:27:in `downto'"
DBG> : "../weakref_bug.rb:27:in `each'"
DBG> : "../weakref_bug.rb:27:in `part'"
DBG> : "../weakref_bug.rb:38:in `block in <main>'"
DBG> : "../weakref_bug.rb:36:in `each'"
DBG> : "../weakref_bug.rb:36:in `<main>'"
Abort trap: 6 (core dumped)


-- 
http://redmine.ruby-lang.org