Project

General

Profile

Bug #17343

Ractor can't clone frozen structures

Added by marcandre (Marc-Andre Lafortune) about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 3.0.0dev (2020-11-26T00:37:38Z master af80df1820) [x86_64-darwin17]
[ruby-core:101087]

Description

Ractor.new([[]].freeze) {} # => FrozenError

See https://github.com/ruby/ruby/pull/3817

#1

Updated by ko1 (Koichi Sasada) about 2 months ago

  • Status changed from Open to Closed

Applied in changeset git|8247b8eddeb2a504a5c9776d1f77d413c8146897.


should not use rb_ary_modify()

ractor_copy() used rb_ary_modify() to make sure this array is not
sharing anything, but it also checks frozen flag. So frozen arrays
raises an error. To solve this issue, this patch introduces new
function rb_ary_cancel_sharing() which makes sure the array does not
share another array and it doesn't check frozen flag.
[Bug #17343]

A test is quoted from https://github.com/ruby/ruby/pull/3817

Updated by marcandre (Marc-Andre Lafortune) about 2 months ago

  • Status changed from Closed to Open

Cool. You'll need to do the same for strings though...

$ ruby -e 'Ractor.new(String.new.instance_eval { @x = []; freeze}){}'
<internal:ractor>:38:in `new': can't modify frozen #<Class:#<String:0x00007fec13883478>>: "" (FrozenError)
    from -e:1:in `<main>'

Updated by ko1 (Koichi Sasada) about 1 month ago

  • Status changed from Open to Closed

fixed 764de7566ffa3fe828abf13ec93d76515ba27dd1

Also available in: Atom PDF