summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--gc.c4
-rw-r--r--test/ruby/test_gc.rb14
3 files changed, 24 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a5cae90a53..745f9c9ff1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon May 28 12:03:04 2012 Narihiro Nakamura <authornari@gmail.com>
+
+ * 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 <ko1@atdot.net>
* benchmark/bm_vm1_lvar_init.rb: added.
diff --git a/gc.c b/gc.c
index 4a96127bf2..92f2e37e17 100644
--- a/gc.c
+++ b/gc.c
@@ -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));
}
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index adcf85e79e..782d8fde3d 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -78,6 +78,20 @@ class TestGc < Test::Unit::TestCase
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",