Skip to content

Commit

Permalink
* gc.c (obj_free): doesn't free a method table if it doesn't
Browse files Browse the repository at this point in the history
  exits. [ruby-dev:44436]
* test/ruby/test_gc.rb (class TestGc): added the test case for
  this issue.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
authorNari committed May 28, 2012
1 parent 92b6597 commit e2f4f34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Mon May 28 12:03:04 2012 Narihiro Nakamura <[email protected]>

* gc.c (obj_free): doesn't free a method table if it doesn't
exits. [ruby-dev:44436]
* test/ruby/test_gc.rb (class TestGc): added the test case for
this issue.

Sun May 27 23:37:48 2012 Koichi Sasada <[email protected]>

* benchmark/bm_vm1_lvar_init.rb: added.
Expand Down
4 changes: 3 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,9 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_MODULE:
case T_CLASS:
rb_clear_cache_by_class((VALUE)obj);
rb_free_m_table(RCLASS_M_TBL(obj));
if (RCLASS_M_TBL(obj)) {
rb_free_m_table(RCLASS_M_TBL(obj));
}
if (RCLASS_IV_TBL(obj)) {
st_free_table(RCLASS_IV_TBL(obj));
}
Expand Down
14 changes: 14 additions & 0 deletions test/ruby/test_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ def obj.bar() raise "obj.foo is called, but this is obj.bar" end
EOS
end

def test_singleton_method_added
assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:44436]")
class BasicObject
def singleton_method_added(mid)
raise
end
end
b = proc {}
class << b; end
b.clone rescue nil
GC.start
EOS
end

def test_gc_parameter
env = {
"RUBY_GC_MALLOC_LIMIT" => "60000000",
Expand Down

0 comments on commit e2f4f34

Please sign in to comment.