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=-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 A0AF61F5AE for ; Fri, 10 Jul 2020 22:20:42 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0372D120A99; Sat, 11 Jul 2020 07:20:05 +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 942D2120A97 for ; Sat, 11 Jul 2020 07:20:02 +0900 (JST) Received: by filterdrecv-p3mdw1-75c584b9c6-sw86w with SMTP id filterdrecv-p3mdw1-75c584b9c6-sw86w-19-5F08E9AB-4 2020-07-10 22:20:27.095762317 +0000 UTC m=+1228257.082832858 Received: from herokuapp.com (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id -hb2mlkpRAm-4_XSEqRFXw for ; Fri, 10 Jul 2020 22:20:26.990 +0000 (UTC) Date: Fri, 10 Jul 2020 22:20:27 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 74909 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17007 X-Redmine-Issue-Author: Eregon X-Redmine-Issue-Assignee: shugo X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIpfLgYBSCRxMMLFlBF6XFgjKYsy0+2fEH9ym=2Fs?= =?us-ascii?Q?5h7QP0dktwyTEOY3b73l2fP4vv1kOzT+ljOcn1v?= =?us-ascii?Q?kchK9ovFlPt1lU5BvtbpKZBJkaut6JOvtAPWv24?= =?us-ascii?Q?bKd3L4KUuRhkahnICyyyrwO2Jm=2FSJG232J2fAz3?= =?us-ascii?Q?FJpZXbvEsg3uLGVbM=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99119 Subject: [ruby-core:99119] [Ruby master Bug#17007] SystemStackError when using super inside Module included and lexically inside refinement 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 #17007 has been updated by jeremyevans0 (Jeremy Evans). After more analysis, I've determined that this issue is due to CREF handling in method lookup in `search_refined_method`. It fails in the lexical case because the module is affected by the refinement (refinement blocks have an implicit `using` of the refinement themselves, I guess). You can reproduce the SystemStackError outside of the lexical case by having the refinement activated at the point of method definition: ```ruby class C def foo ["C"] end end module M; end refinement = Module.new do R = refine C do def foo ["R"] + super end include M end end using refinement M.define_method(:foo){["M"] + super()} p C.new.foo ``` You can fix the issue by skipping any refined method during super lookup if the current method also uses the same refinement. I implemented this in a pull request: https://github.com/ruby/ruby/pull/3309. ---------------------------------------- Bug #17007: SystemStackError when using super inside Module included and lexically inside refinement https://bugs.ruby-lang.org/issues/17007#change-86494 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * Assignee: shugo (Shugo Maeda) * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- ```ruby class C def foo ["C"] end end refinement = Module.new do R = refine C do def foo ["R"] + super end include Module.new { def foo ["M"] + super end } end end using refinement p C.new.foo ``` gives ``` $ ruby bug_refine_super.rb Traceback (most recent call last): 10920: from bug_refine_super.rb:22:in `
' 10919: from bug_refine_super.rb:10:in `foo' 10918: from bug_refine_super.rb:15:in `foo' 10917: from bug_refine_super.rb:10:in `foo' 10916: from bug_refine_super.rb:15:in `foo' 10915: from bug_refine_super.rb:10:in `foo' 10914: from bug_refine_super.rb:15:in `foo' 10913: from bug_refine_super.rb:10:in `foo' ... 10908 levels... 4: from bug_refine_super.rb:15:in `foo' 3: from bug_refine_super.rb:10:in `foo' 2: from bug_refine_super.rb:15:in `foo' 1: from bug_refine_super.rb:10:in `foo' bug_refine_super.rb:15:in `foo': stack level too deep (SystemStackError) ``` OTOH defining the module lexically outside of `refine` works: ```ruby m = Module.new { def foo ["M"] + super end } refinement = Module.new do R = refine C do def foo ["R"] + super end include m end end # result: ["R", "M", "C"] ``` -- https://bugs.ruby-lang.org/