summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-02-28 23:58:33 -0800
committerGitHub <noreply@github.com>2020-02-28 23:58:33 -0800
commitadcf0316d1ecedae2a9157ad941550e0c0fb510b (patch)
treeb9fc854a840690799088e00677c62fc0beb96a96 /test/ruby
parenta8dcab723316997d9e01c89d6df969edce75bdca (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
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_jit.rb32
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