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:
parent
38af38edcb
commit
0d81177c20
Notes:
git
2024-12-24 02:40:18 +00:00
5
ractor.c
5
ractor.c
@ -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) {
|
cr->threads.cnt == cr->threads.blocking_cnt + 1) {
|
||||||
// change ractor status: running -> blocking
|
// change ractor status: running -> blocking
|
||||||
rb_vm_t *vm = GET_VM();
|
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_ractor_blocking_cnt_inc(vm, cr, file, line);
|
||||||
}
|
}
|
||||||
RB_VM_UNLOCK();
|
RB_VM_LOCK_LEAVE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,4 +126,14 @@ class TestEncoding < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end;
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user