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.9 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 E2E721F8C6 for ; Thu, 12 Aug 2021 13:31:45 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1D8FF1208AA; Thu, 12 Aug 2021 22:30:24 +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 2FCB7120BB4 for ; Thu, 12 Aug 2021 22:30:20 +0900 (JST) Received: by filterdrecv-7c9f9f88f-xw28c with SMTP id filterdrecv-7c9f9f88f-xw28c-1-611522B8-73 2021-08-12 13:31:36.670029215 +0000 UTC m=+1451506.253107101 Received: from herokuapp.com (unknown) by ismtpd0178p1iad2.sendgrid.net (SG) with ESMTP id BdOku0s8TlSwIpe02w5o5A for ; Thu, 12 Aug 2021 13:31:36.580 +0000 (UTC) Date: Thu, 12 Aug 2021 13:31:36 +0000 (UTC) From: mkaeppler@gitlab.com Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17806 X-Redmine-Issue-Author: alanwu X-Redmine-Sender: mk 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: 81036 X-SG-EID: =?us-ascii?Q?2IjJ2mvoEzbWaTrhskTR5Z6Jr7Htund8XDSpIP9M8J9QCRLRVG6=2FJsqY++hX2p?= =?us-ascii?Q?wFIYiEggLLShOv73sRTsXuPft+D+1BmF0Quw2nS?= =?us-ascii?Q?QsJwelU1Ki4C3yPlMmn42VFTgBWRZiauSy6zBD=2F?= =?us-ascii?Q?dwACiqWiqIDZgJpNjprybbPTSoUtE0jkl56jdle?= =?us-ascii?Q?sk40GyXsD4HXUaOUVsii9i15lFZWKSBL8iw=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 104897 Subject: [ruby-core:104897] [Ruby master Bug#17806] Bad interaction between method cache, prepend, and refinements 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17806 has been updated by mk (Matthias K=E4ppler). Thanks @alanwu! I forgot to watch this issue so I was never notified of your response. Sorr= y for the delay. > I would try running these two lines before requiring the test file that c= ontains the | call: > = > ``` > iseq =3D RubyVM::InstructionSequence > iseq.compile_option =3D iseq.compile_option.merge(specialized_instruction= : false) > ``` Thank you so much -- I was eventually able to verify that this is indeed th= e problem. Moving this in front of `application.rb` (this is a Rails app) f= ixes the test. > If that fixes the issue I would try to run the test unmodified with a bui= ld of the master branch. Yep, we have a system in place that applies custom patches to our CI and pr= oduction Rubies, and I was able to verify that applying https://bugs.ruby-l= ang.org/projects/ruby-master/repository/git/revisions/fb4cf204a662a8cd9dafe= f6f31f2bd0db9129abe/diff and https://bugs.ruby-lang.org/projects/ruby-maste= r/repository/git/revisions/fa0279d947c3962c3f8c32852278d3ebb964cb19/diff to= `3.0.2` resolves the issue (the former turns the test green, the latter fi= xes a segfault I ran into after applying the former). Again, I really appreciate your help -- this caused me quite the headache := -) ---------------------------------------- Bug #17806: Bad interaction between method cache, prepend, and refinements https://bugs.ruby-lang.org/issues/17806#change-93257 * Author: alanwu (Alan Wu) * Status: Closed * Priority: Normal * ruby -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin19] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: DONE ---------------------------------------- I'm running into a couple of issues with Ruby 3's new method cache and refinements. The first script raises `SystemStackError` unexpectedly: ```ruby module R1 refine Hash do def foo; :r1; end end end class Hash prepend(Module.new) end class Hash def foo; end end {}.method(:foo) # put it on pCMC module R2 refine Hash do def foo; :r2; end end end {}.foo # SystemStackError ``` The second script calls the wrong method: ```ruby klass =3D Class.new { def foo; end } _refinement =3D Module.new do refine(klass) { def foo; :refined; end } end klass.prepend(Module.new) klass.new.foo # cache foo klass.define_method(:foo) { :second } p klass.new.foo # prints nil. False caching. ``` I submitted a GitHub PR to fix the issue: https://github.com/ruby/ruby/pull= /4386 -- = https://bugs.ruby-lang.org/ Unsubscribe: