summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-09-01 23:13:54 -0400
committerAaron Patterson <aaron.patterson@gmail.com>2020-09-25 09:27:49 -0700
commit24820d508bc89775e10e4e3e6e07e192540cb4a2 (patch)
tree6d61996799f1c7903164b0c67039b35054d5c87d /test
parent3a00f2a0f4325cbeea96fe3b6fbc774e8a172920 (diff)
Return nil when argument to ObjectSpace.internal_class_of is T_IMEMO
The added test case crashes the interpreter because it makes ObjectSpace.internal_class_of return the second VALUE slot of an AST imemo object. The second VALUE slot of `struct rb_ast_struct` is not a VALUE and not a pointer to a Ruby object.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3503
Diffstat (limited to 'test')
-rw-r--r--test/objspace/test_objspace.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index f9e6e82e8f..b3f7a56e51 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -516,6 +516,11 @@ class TestObjSpace < Test::Unit::TestCase
assert_operator i, :>, 0
end
+ def test_internal_class_of_on_ast
+ children = ObjectSpace.reachable_objects_from(RubyVM::AbstractSyntaxTree.parse("kadomatsu"))
+ children.each {|child| ObjectSpace.internal_class_of(child).itself} # this used to crash
+ end
+
def traverse_super_classes klass
while klass
klass = ObjectSpace.internal_super_of(klass)