🌐 AI搜索 & 代理 主页
Skip to content

Commit f88eee1

Browse files
committed
Prevent ifunc procs from being made shareable
[Bug #21775]
1 parent d02c971 commit f88eee1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

test/ruby/test_ractor.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def test_max_cpu_1
201201
RUBY
202202
end
203203

204+
# [Bug #21775]
205+
def test_ifunc_proc_not_shareable
206+
h = Hash.new { self }
207+
pr = h.to_proc
208+
assert_unshareable(pr, /not supported yet/, exception: RuntimeError)
209+
end
210+
204211
def assert_make_shareable(obj)
205212
refute Ractor.shareable?(obj), "object was already shareable"
206213
Ractor.make_shareable(obj)

vm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,10 @@ rb_proc_ractor_make_shareable(VALUE self, VALUE replace_self)
15941594
proc->is_isolated = TRUE;
15951595
}
15961596
else {
1597-
VALUE proc_self = vm_block_self(vm_proc_block(self));
1597+
const struct rb_block *block = vm_proc_block(self);
1598+
if (block->type != block_type_symbol) rb_raise(rb_eRuntimeError, "not supported yet");
1599+
1600+
VALUE proc_self = vm_block_self(block);
15981601
if (!rb_ractor_shareable_p(proc_self)) {
15991602
rb_raise(rb_eRactorIsolationError,
16001603
"Proc's self is not shareable: %" PRIsVALUE,

0 commit comments

Comments
 (0)