I cannot reproduce above error. However, Bug #4168 and #5350 seem not solved.
I got NoMethodError by the following script. WeakRef object has reference to different object from originally associated.
This issue was solved with changeset r37826.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
Fix finalize of WeakRef
gc.c (wmap_final_func): remove WeakRef object reference from the
array.
gc.c (wmap_finalize): remove recycled object references from weak
map hash properly. How to get object reference from object id was
wrong. st_delete() doesn't work properly if key and value arguments
are same. The key of obj2wmap is referenced object and the value of obj2wmap is WeakRef array.
gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
definition.
test/test_weakref.rb (TestWeakRef#test_not_reference_different_object): add a test for
above. [ruby-core:49044] [Bug #7304]
This fix causes segv, which was pointed out at r37831. Thank you, naruse-san.
I found rb_ary_delete(ary, obj) is not usable when doing WeakRef finalize because rb_ary_delete() calls rb_equal() against GC'ed WeakRef object.
Instead just comparing VALUE by == seems good for this case. I'll fix later.
This issue was solved with changeset r37834.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
Fix WeakRef finalize
array.c (rb_ary_delete_same_obj): new function for WeakRef.
This deletes same objects as item argument in the array.
internal.h (rb_ary_delete_same_obj): add a declaration.
gc.c (wmap_final_func): remove WeakRef object reference from the
array. rb_ary_delete() is not usable because it uses rb_equal() to
compare object references.
gc.c (wmap_finalize): remove recycled object references from weak
map hash properly. How to get object reference from object id was
wrong. st_delete() doesn't work properly if key and value arguments
are same. The key of obj2wmap is referenced object and the value of obj2wmap is WeakRef array.
gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
definition.
test/test_weakref.rb (TestWeakRef#test_not_reference_different_object, TestWeakRef#test_weakref_finalize): add tests for above. [ruby-core:49044] [Bug #7304]