From 46215c1e90183952be55bead4c04cc8b6a8b8ee5 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 21 Jul 2015 19:04:56 +0000 Subject: [PATCH] * gc.c (internal_object_p): Now a singleton classes appear by ObjectSpace.each_object. [Bug #11360] * test/ruby/test_objectspace.rb: add a test about it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ gc.c | 3 --- test/ruby/test_objectspace.rb | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad4e8b1839..fd85131226 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jul 22 03:37:39 2015 Koichi Sasada + + * gc.c (internal_object_p): Now a singleton classes appear by + ObjectSpace.each_object. [Bug #11360] + + * test/ruby/test_objectspace.rb: add a test about it. + Tue Jul 21 21:21:33 2015 Nobuyoshi Nakada * thread.c (do_select): replace switch and goto with a loop to diff --git a/gc.c b/gc.c index 195be83ec6..36c4e01320 100644 --- a/gc.c +++ b/gc.c @@ -2319,9 +2319,6 @@ internal_object_p(VALUE obj) case T_NODE: case T_ZOMBIE: break; - case T_CLASS: - if (FL_TEST(p, FL_SINGLETON)) - break; default: if (!p->as.basic.klass) break; return 0; diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index d519041f0b..a57c7ea1d1 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -109,4 +109,20 @@ End p Thread.current[:__recursive_key__] end; end + + def test_each_object_singleton_class + assert_separately([], <<-End) + class C + class << self + $c = self + end + end + + exist = false + ObjectSpace.each_object(Class){|o| + exist = true if $c == o + } + assert(exist, 'Bug #11360') + End + end end