diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2021-04-26 18:11:46 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2021-04-26 22:46:51 +0900 |
commit | 2c7d3b3a722c4636ab1e9d289cbca47ddd168d3e (patch) | |
tree | cb21ba7bca3f68e93587d3e75e07990c443c9a51 /test/ruby | |
parent | 5219b4ddb4b89dfe8a951da75f5ab78431781d7f (diff) | |
download | ruby-2c7d3b3a722c4636ab1e9d289cbca47ddd168d3e.tar.gz |
node.c (rb_ast_new): imemo_ast is WB-unprotected
Previously imemo_ast was handled as WB-protected which caused a segfault
of the following code:
# shareable_constant_value: literal
M0 = {}
M1 = {}
...
M100000 = {}
My analysis is here: `shareable_constant_value: literal` creates many
Hash instances during parsing, and add them to node_buffer of imemo_ast.
However, the contents are missed because imemo_ast is incorrectly
WB-protected.
This changeset makes imemo_ast as WB-unprotected.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_gc.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 1f75a34cac..f10946bd39 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -494,4 +494,11 @@ class TestGc < Test::Unit::TestCase b = 1000.times.map { Object.new.object_id } assert_empty(a & b) end + + def test_ast_node_buffer + # https://github.com/ruby/ruby/pull/4416 + Module.new.class_eval do + eval((["# shareable_constant_value: literal"] + (0..100000).map {|i| "M#{ i } = {}" }).join("\n")) + end + end end |