Ractor.shareable_proc(&pr) should copy pr

`pr` should not change on this method.
This commit is contained in:
Koichi Sasada 2025-12-05 02:48:05 +09:00
parent d105709f2b
commit 02cddcc2be
Notes: git 2025-12-05 01:45:31 +00:00
2 changed files with 11 additions and 1 deletions

View File

@ -157,6 +157,16 @@ assert_equal '[:a, :b, :c, :d, :e]', %q{
Ractor.shareable_proc(&closure).call
}
# Ractor.make_shareable makes a copy of given Proc
assert_equal '[true, true]', %q{
pr1 = Proc.new do
self
end
pr2 = Ractor.shareable_proc(&pr1)
[pr1.call == self, pr2.call == nil]
}
# Ractor::IsolationError cases
assert_equal '3', %q{
ok = 0

View File

@ -2376,7 +2376,7 @@ ractor_shareable_proc(rb_execution_context_t *ec, VALUE replace_self, bool is_la
}
else {
VALUE proc = is_lambda ? rb_block_lambda() : rb_block_proc();
return rb_proc_ractor_make_shareable(proc, replace_self);
return rb_proc_ractor_make_shareable(rb_proc_dup(proc), replace_self);
}
}