1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

mjit.c: don't let MJIT.pause hang on full active units

test/ruby/test_rubyvm_mjit.rb: add reproductive test

[Bug #15071]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-10-19 15:08:55 +00:00
parent 1a7249bc03
commit 320d7c54ba
2 changed files with 13 additions and 1 deletions

2
mjit.c
View file

@ -647,7 +647,7 @@ mjit_pause(int wait_p)
tv.tv_sec = 0;
tv.tv_usec = 1000;
while (unit_queue.length > 0) {
while (unit_queue.length > 0 && active_units.length < mjit_opts.max_cache_size) { /* inverse of condition that waits for mjit_worker_wakeup */
CRITICAL_SECTION_START(3, "in mjit_pause for a worker wakeup");
rb_native_cond_broadcast(&mjit_worker_wakeup);
CRITICAL_SECTION_FINISH(3, "in mjit_pause for a worker wakeup");

View file

@ -33,6 +33,18 @@ class TestRubyVMMJIT < Test::Unit::TestCase
)
end
def test_pause_does_not_hang_on_full_units
out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false)
i = 0
while i < 11
eval("def mjit#{i}; end; mjit#{i}")
i += 1
end
print RubyVM::MJIT.pause
EOS
assert_equal('true', out)
end
def test_pause_wait_false
out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
i = 0