From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 291161B8009D for ; Sun, 23 Apr 2017 15:36:15 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id BD9FEB5D841 for ; Sun, 23 Apr 2017 16:17:00 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 44E8018CC81C for ; Sun, 23 Apr 2017 16:17:01 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id CAA4612075C; Sun, 23 Apr 2017 16:16:59 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8CFE6120736 for ; Sun, 23 Apr 2017 16:16:56 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=CxjN9+r4G6OV6chz6vupQfIX21A=; b=v1y6fluD9yBD/lDI7D Ujv19WW8Y0KQGNSG7SN71Klr3xMA+/R/xEGGkDdhOFrAyyOej8T4Sk6RXMgScHYD THMBWwGAb8vZhm4GsgQsrM9UvVQyMj/QPkc5hodpCy0e+JU16fVYWe7fBRE1ppoG nzC9WCA9EY5+6jeJGLofaakyw= Received: by filter0103p1las1.sendgrid.net with SMTP id filter0103p1las1-28400-58FC54E5-5 2017-04-23 07:16:53.134733578 +0000 UTC Received: from herokuapp.com (ec2-54-159-232-221.compute-1.amazonaws.com [54.159.232.221]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id HMrQMUSMSSez-vBEday9Tw for ; Sun, 23 Apr 2017 07:16:53.055 +0000 (UTC) Date: Sun, 23 Apr 2017 07:16:53 +0000 From: ruby@herwinw.nl To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 55872 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13498 X-Redmine-Issue-Author: herwin X-Redmine-Sender: herwin 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7MpxqDCUI9OnUXL592dBOmQnRAPR6hh3Kzo5 4L58NDcL2HgTwbaGzBIN08Y5WlNri7Ka3Yld8VG2nUSoay/jVwpXjVBE91KUx+vm+CjFDeAUZ+1wo1 Hm9UWgYtOUuUBI+qoj+rvKSc8St2C+8WtF5K X-ML-Name: ruby-core X-Mail-Count: 80835 Subject: [ruby-core:80835] [Ruby trunk Bug#13498] Weakref, Weakmap and define_finalizer don't work on frozen 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 #13498 has been reported by herwin (Herwin W). ---------------------------------------- Bug #13498: Weakref, Weakmap and define_finalizer don't work on frozen objects https://bugs.ruby-lang.org/issues/13498 * Author: herwin (Herwin W) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] (but seen the same issue with 2.3 and 2.1) * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- I'm just creating a single ticket for these issues, I guess they're actually all the same (I've seen weakref uses weakmap, not sure about define_finalizer). ```ruby require 'weakref' map = ObjectSpace::WeakMap.new o = Object.new o.freeze begin WeakRef.new(o) rescue => e STDERR.puts e end begin map[o] = 'foo' rescue => e STDERR.puts e end begin map['bar'] = o rescue => e STDERR.puts e end begin ObjectSpace.define_finalizer(o, ->(id) { p id }) rescue => e STDERR.puts e end ``` Every statement here raises the runtime error "can't modify frozen Object". The documentation doesn't mention that frozen objects are not allowed, the closest reference we get is a short paragraph in WeakRef: "With this you will have to limit your self to String keys, otherwise you will get an ArgumentError because WeakRef cannot create a finalizer for a Symbol. Symbols are immutable and cannot be garbage collected" -- https://bugs.ruby-lang.org/