🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/ruby/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ def test_max_cpu_1
RUBY
end

def test_symbol_proc_is_shareable
pr = :symbol.to_proc
assert_make_shareable(pr)
end

# [Bug #21775]
def test_ifunc_proc_not_shareable
h = Hash.new { self }
pr = h.to_proc
assert_unshareable(pr, /not supported yet/, exception: RuntimeError)
end

def assert_make_shareable(obj)
refute Ractor.shareable?(obj), "object was already shareable"
Ractor.make_shareable(obj)
Expand Down
5 changes: 4 additions & 1 deletion vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,10 @@ rb_proc_ractor_make_shareable(VALUE self, VALUE replace_self)
proc->is_isolated = TRUE;
}
else {
VALUE proc_self = vm_block_self(vm_proc_block(self));
const struct rb_block *block = vm_proc_block(self);
if (block->type != block_type_symbol) rb_raise(rb_eRuntimeError, "not supported yet");

VALUE proc_self = vm_block_self(block);
if (!rb_ractor_shareable_p(proc_self)) {
rb_raise(rb_eRactorIsolationError,
"Proc's self is not shareable: %" PRIsVALUE,
Expand Down
Loading