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-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 642F81F4B4 for ; Wed, 7 Oct 2020 16:02:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8F6B5120B07; Thu, 8 Oct 2020 01:01:41 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 886FB120B01 for ; Thu, 8 Oct 2020 01:01:39 +0900 (JST) Received: by filterdrecv-p3mdw1-5dd6bc5999-h57bn with SMTP id filterdrecv-p3mdw1-5dd6bc5999-h57bn-18-5F7DE680-1C6 2020-10-07 16:02:08.78842267 +0000 UTC m=+1361012.340675233 Received: from herokuapp.com (unknown) by ismtpd0090p1mdw1.sendgrid.net (SG) with ESMTP id txC-R2OuRG6J7kLP-XXzYg for ; Wed, 07 Oct 2020 16:02:08.594 +0000 (UTC) Date: Wed, 07 Oct 2020 16:02:08 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76165 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17188 X-Redmine-Issue-Author: Eregon X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: Eregon 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-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr1BhEhadDpCe4YFOxwR7L?= =?us-ascii?Q?12oybYYrz79bulkEcGqXbXl9Tx9=2FPwJ4gDxYXnX?= =?us-ascii?Q?Txkwh+t+jMGnnXSHdhBxK2Qg0YoPtDh6vDfsVbE?= =?us-ascii?Q?stiYArL3iEGtZdW8Qapiq=2FOaEqVN1diN0RolfKs?= =?us-ascii?Q?wQlevyd8c6Qp1YLC+kfClcf3BmvG=2FoCC1AQA9jI?= =?us-ascii?Q?w6YvxfsF=2FNcWkNaGY=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 100331 Subject: [ruby-core:100331] [Ruby master Bug#17188] Freeze Encoding objects for Ractor 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 #17188 has been updated by Eregon (Benoit Daloze). Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ruby -v set to ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-linux] Assignee set to ko1 (Koichi Sasada) Tracker changed from Feature to Bug Changing this to a bug, because it can cause unsafe sharing: ```ruby irb(main):003:0> Encoding::UTF_8.instance_variable_set(:@foo, Object.new) => # irb(main):004:0> Ractor.new { p "b".encoding.instance_variable_get("@foo") } # ``` ---------------------------------------- Bug #17188: Freeze Encoding objects for Ractor https://bugs.ruby-lang.org/issues/17188#change-87907 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: 3.0 * ruby -v: ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Currently Encoding objects are not frozen: ``` $ ruby -ve 'p Encoding::US_ASCII.frozen?' ruby 3.0.0dev (2020-09-25T08:28:42Z master 81dc37b1b4) [x86_64-linux] false ``` That means they cannot be accessed in a Ractor: ```ruby irb(main):001:0> Encoding::US_ASCII => # irb(main):002:0> Ractor.new { Encoding::US_ASCII } :38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues. => # # terminated with exception (report_on_exception is true): (irb):2:in `block in irb_binding': can not access non-sharable objects in constant Encoding::US_ASCII by non-main Ractor. (NameError) ``` And `Ractor.new { p "".encoding }` is likely violating the Ractor guarantees. I think we can make all Encoding instances frozen. Making them frozen is also useful for code sharing, which TruffleRuby aims to support via the GraalVM Engine/Context API. cc @ko1 -- https://bugs.ruby-lang.org/