diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-02-28 23:58:33 -0800 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2020-03-15 19:35:24 +0900 |
commit | a36ead3f4fe801ddaebe6d1ed905e9e3276dbac7 (patch) | |
tree | 53de69643c057929db9305329fa16989b96c9ded /test | |
parent | 17e925b9917f4877f2da8c64316feb3ce1ca2932 (diff) |
Prevent unloading methods used in root_fiber while calling another Fiber (#2939)
Fixing SEGVs like:
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400
[Bug #16664]
(cherry picked from commit adcf0316d1ecedae2a9157ad941550e0c0fb510b)
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_jit.rb | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index adb66036de..e3d8f9cee2 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -12,6 +12,10 @@ class TestJIT < Test::Unit::TestCase /\AJIT inline: .+\n\z/, /\ASuccessful MJIT finish\n\z/, ] + MAX_CACHE_PATTERNS = [ + /\AJIT compaction \([^)]+\): .+\n\z/, + /\ANo units can be unloaded -- .+\n\z/, + ] # trace_* insns are not compiled for now... TEST_PENDING_INSNS = RubyVM::INSTRUCTION_NAMES.select { |n| n.start_with?('trace_') }.map(&:to_sym) + [ @@ -611,11 +615,7 @@ class TestJIT < Test::Unit::TestCase end def test_nothing_to_unload_with_jit_wait - ignorable_patterns = [ - /\AJIT compaction \([^)]+\): .+\n\z/, - /\ANo units can be unloaded -- .+\n\z/, - ] - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 11, max_cache: 10, ignorable_patterns: ignorable_patterns) + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 11, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS) begin; def a1() a2() end def a2() a3() end @@ -632,6 +632,28 @@ class TestJIT < Test::Unit::TestCase end; end + def test_unload_units_on_fiber + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 12, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS) + begin; + def a1() a2(false); a2(true) end + def a2(a) a3(a) end + def a3(a) a4(a) end + def a4(a) a5(a) end + def a5(a) a6(a) end + def a6(a) a7(a) end + def a7(a) a8(a) end + def a8(a) a9(a) end + def a9(a) a10(a) end + def a10(a) + if a + Fiber.new { a11 }.resume + end + end + def a11() print('hello') end + a1 + end; + end + def test_unload_units_and_compaction Dir.mktmpdir("jit_test_unload_units_") do |dir| # MIN_CACHE_SIZE is 10 |