ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: ko1@atdot.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:101189] [Ruby master Bug#17359] Ractor copy mode is not Ractor-safe
Date: Tue, 01 Dec 2020 18:09:31 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-88870.20201201180931.182@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17359.20201201082937.182@ruby-lang.org

Issue #17359 has been updated by ko1 (Koichi Sasada).


Eregon (Benoit Daloze) wrote in #note-7:
> An idea: copy everything in the source Ractor as currently, and then `move` the resulting copied object.
> That way, the source Ractor might keep references to copied objects, but it won't be able to use them.
> This actually means a partial copy for `move` on top of the original deep copy though.

Complete idea, but it makes two objects per one. mmm.

Doing it if user-defined `initialize_copy/clone` is detected?

----------------------------------------
Bug #17359: Ractor copy mode is not Ractor-safe
https://bugs.ruby-lang.org/issues/17359#change-88870

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.0.0dev (2020-11-30T10:06:25Z master 89774a938a) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
It should not be possible to mutate an object across Ractors, but the copy mode allows it currently:

```ruby
class Foo
  attr_accessor :x

  def initialize_copy(*)
    $last = self
    super
  end
end
o = Foo.new
o.x = 42

r = Ractor.new(o) do |copy|
  puts copy.x # => 42
  Ractor.yield :sync
  Ractor.yield :sync
  puts copy.x # => 666
end
r.take # => :sync
$last.x = 666
r.take # => :sync
r.take
```

Maybe the `copy` object should be marked as moved?



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2020-12-01 18:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01  8:29 [ruby-core:101174] [Ruby master Bug#17359] Ractor copy mode is not Ractor-safe marcandre-ruby-core
2020-12-01  9:14 ` [ruby-core:101175] " ko1
2020-12-01  9:23 ` [ruby-core:101176] " marcandre-ruby-core
2020-12-01 13:09 ` [ruby-core:101178] " daniel
2020-12-01 17:30 ` [ruby-core:101183] " ko1
2020-12-01 17:36 ` [ruby-core:101184] " ko1
2020-12-01 17:53 ` [ruby-core:101187] " ko1
2020-12-01 17:59 ` [ruby-core:101188] " eregontp
2020-12-01 18:09 ` ko1 [this message]
2020-12-01 18:29 ` [ruby-core:101190] " marcandre-ruby-core
2020-12-01 18:44 ` [ruby-core:101191] " ko1
2020-12-01 20:40 ` [ruby-core:101194] " marcandre-ruby-core
2020-12-01 22:01 ` [ruby-core:101195] " daniel
2020-12-01 22:10 ` [ruby-core:101196] " marcandre-ruby-core
2020-12-02 14:00 ` [ruby-core:101202] " daniel
2020-12-02 17:42 ` [ruby-core:101206] " marcandre-ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-88870.20201201180931.182@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).