diff --git a/ChangeLog b/ChangeLog index 8f84f812fd..bdffa1e568 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 18 17:17:36 2012 Nobuyoshi Nakada + + * gc.c (free_method_entry_i): method entry may be in + unlinked_method_entry_list. [ruby-core:43383][Bug #6171] + Sun Mar 18 15:27:31 2012 Tanaka Akira * compile.c: typo fix by Run Paint Run Run. diff --git a/gc.c b/gc.c index cd136cb4dd..76f58ee0e6 100644 --- a/gc.c +++ b/gc.c @@ -1709,7 +1709,9 @@ mark_m_tbl(rb_objspace_t *objspace, st_table *tbl, int lev) static int free_method_entry_i(ID key, rb_method_entry_t *me, st_data_t data) { - rb_free_method_entry(me); + if (!me->mark) { + rb_free_method_entry(me); + } return ST_CONTINUE; } diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index c784bd357e..ed04570e6a 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -461,4 +461,16 @@ class TestMethod < Test::Unit::TestCase assert_nothing_raised { v.instance_eval { mv2 } } assert_nothing_raised { v.instance_eval { mv3 } } end + + def test_bound_method_entry + bug6171 = '[ruby-core:43383]' + assert_ruby_status([], <<-EOC, bug6171) + class Bug6171 + def initialize(target) + define_singleton_method(:reverse, target.method(:reverse).to_proc) + end + end + 1000.times {p = Bug6171.new('test'); 10000.times {p.reverse}} + EOC + end end