Fix calls to require_internal in multi-ractor mode

After a ractor is started (multi-ractor mode), any calls to
require_internal will hang the process due to deadlock. For example,
loading a new encoding will deadlock after a ractor starts.

Fixes [Bug #19562]
This commit is contained in:
lukeg 2023-04-04 16:24:59 -04:00 committed by Koichi Sasada
parent 38af38edcb
commit 0d81177c20
Notes: git 2024-12-24 02:40:18 +00:00
2 changed files with 12 additions and 3 deletions

View File

@ -2341,13 +2341,12 @@ ractor_check_blocking(rb_ractor_t *cr, unsigned int remained_thread_cnt, const c
cr->threads.cnt == cr->threads.blocking_cnt + 1) {
// change ractor status: running -> blocking
rb_vm_t *vm = GET_VM();
ASSERT_vm_unlocking();
RB_VM_LOCK();
RB_VM_LOCK_ENTER();
{
rb_vm_ractor_blocking_cnt_inc(vm, cr, file, line);
}
RB_VM_UNLOCK();
RB_VM_LOCK_LEAVE();
}
}

View File

@ -126,4 +126,14 @@ class TestEncoding < Test::Unit::TestCase
end
end;
end
def test_ractor_load_encoding
assert_ractor("#{<<~"begin;"}\n#{<<~'end;'}")
begin;
Ractor.new{}.take
$-w = nil
Encoding.default_external = Encoding::ISO8859_2
assert "[Bug #19562]"
end;
end
end