From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 499331F8C6 for ; Wed, 7 Jul 2021 18:35:33 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6EC18120A88; Thu, 8 Jul 2021 03:34:15 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id E687D120A85 for ; Thu, 8 Jul 2021 03:34:12 +0900 (JST) Received: by filterdrecv-7d77f865b7-56bn4 with SMTP id filterdrecv-7d77f865b7-56bn4-1-60E5F3EC-22 2021-07-07 18:35:24.296910866 +0000 UTC m=+597243.958197440 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id klPexBL8SqezfSOke7lcxA for ; Wed, 07 Jul 2021 18:35:24.047 +0000 (UTC) Date: Wed, 07 Jul 2021 18:35:24 +0000 (UTC) From: i@orlando-labs.com Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 18023 X-Redmine-Issue-Author: slowpilot X-Redmine-Sender: slowpilot X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 80663 X-SG-EID: =?us-ascii?Q?d9ghcwOCxtLmlZpMH09003kypA40JR0VqZY11sbyIwD5aUaC5AiiQJqgy0suH3?= =?us-ascii?Q?cY42zlPe+JEx+L2mx5v5lligCmObGVz=2FUVAEBq=2F?= =?us-ascii?Q?Yl2HR5RN=2F=2FtLJhV2muF0hYeEHPfXOk4ghyJhKq7?= =?us-ascii?Q?ZESU1=2FycGyw0yYKvEp4xuL4uhV6UKH5OvJLX+WF?= =?us-ascii?Q?x8FyHn=2FZ9qIUOEorEe69Kv+tub0d4FnIyoA=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 104537 Subject: [ruby-core:104537] [Ruby master Bug#18023] Ractor#make_shareable changes the values of closured shareable objects X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #18023 has been updated by slowpilot (Ivan Razuvaev). slowpilot (Ivan Razuvaev) wrote: > Hi. I encountered strange behaviour or shareable procs when every even closured shareable variable becomes the FalseClass instance. > > ``` ruby > [usr@srvr ~]$ irb > 3.0.1 :001 > v1, v2, v3, v4 = :a, :b, :c, :d > => [:a, :b, :c, :d] > 3.0.1 :002 > p = Proc.new { p v1, v2, v3, v4 } > => # > 3.0.1 :003 > p.() > :a > :b > :c > :d > => [:a, :b, :c, :d] > 3.0.1 :004 > Ractor.make_shareable(p).() > :a > false > :c > false > => [:a, false, :c, false] > ``` This is stopping from using dynamically defined methods from ractors. E.g. in Ruby [libtorch](https://github.com/orlando-labs/torch.rb/blob/2c8c1c89ded3ac924a19020d6c747582d1c828cc/lib/torch.rb#L256). So after calling rb_ext_ractor_safe in extension, I am trying to do something like: ```ruby cls.define_singleton_method('new', Ractor.make_shareable(Proc.new { ... }) ``` That leads to every second closure assignment to false. ---------------------------------------- Bug #18023: Ractor#make_shareable changes the values of closured shareable objects https://bugs.ruby-lang.org/issues/18023#change-92812 * Author: slowpilot (Ivan Razuvaev) * Status: Open * Priority: Normal * ruby -v: 3.0.0, 3.0.1 * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Hi. I encountered strange behaviour or shareable procs when every even closured shareable variable becomes the FalseClass instance. ``` ruby [usr@srvr ~]$ irb 3.0.1 :001 > v1, v2, v3, v4 = :a, :b, :c, :d => [:a, :b, :c, :d] 3.0.1 :002 > p = Proc.new { p v1, v2, v3, v4 } => # 3.0.1 :003 > p.() :a :b :c :d => [:a, :b, :c, :d] 3.0.1 :004 > Ractor.make_shareable(p).() :a false :c false => [:a, false, :c, false] ``` -- https://bugs.ruby-lang.org/