Project

General

Profile

Actions

Bug #20165

open

Ractors moving a Struct breaks beyond the first 3 fields

Added by codekitchen (Brian Palmer) 10 months ago. Updated 10 months ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
[ruby-core:116085]

Description

Experimenting with Ractors on ruby 3.3.0, and I'm seeing a bug where if you move a struct between ractors, all but the first 3 fields are set to nil.

Foo = Struct.new(:a,:b,:c,:d,:e,:f)

r = Ractor.new {
  foo = Foo[0,0,0,0,0,0]
  p foo
  Ractor.yield(foo, move: true)
}
p r.take

❯ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
❯ ruby rbug.rb       
rbug.rb:3: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<struct Foo a=0, b=0, c=0, d=0, e=0, f=0>
#<struct Foo a=0, b=0, c=0, d=nil, e=nil, f=nil>

This seems specific to moving, if I set move: false the struct makes it across OK.

Updated by luke-gru (Luke Gruber) 10 months ago

I sent a fix for this here https://github.com/ruby/ruby/pull/9910/

Also, currently Ractors are not working well on Ruby 3.3, if you're working with them I suggest staying on 3.2 for now.

Actions

Also available in: Atom PDF

Like0
Like0