[ruby-core:117763] [Ruby master Bug#20468] Segfault on safe navigation in for target

Issue #20468 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by nobu (Nobuyoshi Nakada). I can't imagine what it should do when `foo == nil`. Should be a syntax error probably? ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108175 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by nobu (Nobuyoshi Nakada). Hmmm, may be possible to interpret that code like as `foo&.then {|recv| for recv.bar in []; end}`. Just an idea. ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108176 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by nobu (Nobuyoshi Nakada). Assignee set to matz (Yukihiro Matsumoto) ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108177 * Author: kddnewton (Kevin Newton) * Status: Open * Assignee: matz (Yukihiro Matsumoto) * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by nobu (Nobuyoshi Nakada). Assignee deleted (matz (Yukihiro Matsumoto)) I found that a `for` loop variable is looser than I expected. Not only a safe navigation call, even a constant can be used. I don't think a constant is useful as a loop variable that is expected to be re-assigned. https://github.com/ruby/ruby/pull/10723 ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108178 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by Eregon (Benoit Daloze). Given `for foo.bar in []; end` is valid and does `for.bar = element`, I think `for foo&.bar in []; end` could simply do `for&.bar = element` which is the same as `for.bar = element unless foo.nil?` (`NIL_P(foo)` to be precise). Changing the syntax for `for` variables sounds more risky and likely to unexpectedly disallow some new `lhs` forms when the `lhs` rule is updated, and the `for_var` rule is forgotten to be updated too. ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108179 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by Eregon (Benoit Daloze). IOW I think the segfault could be fixed here without changing what is valid syntax. And given this segfault probably affects older versions too there it seems better to fix the segfault than to change syntax. ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108180 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by zverok (Victor Shepelev). Agree with @Eregon. The code should be more or less equivalent to: ```ruby for temp in [1, 2, 3] foo&.bar = temp end ``` ...which is totally valid and `foo&.bar =` is a no-op (semantically). ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108181 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by kddnewton (Kevin Newton). @nobu it's the same possibilities in `for`, `rescue`, and multi-write. As in: ```ruby for (foo, @foo, @@foo, $foo, Foo, Foo::Foo, foo.foo, foo[foo]) in bar; end begin; rescue => foo; end begin; rescue => @foo; end begin; rescue => @@foo; end begin; rescue => $foo; end begin; rescue => Foo; end begin; rescue => Foo::Foo; end begin; rescue => foo.foo; end begin; rescue => foo[foo]; end (foo, @foo, @@foo, $foo, Foo, Foo::Foo, foo.foo, foo[foo]) = bar ``` ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-108198 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE ruby_3_3 commit:8a2e41d34b135046957e1195a5d4f4967a82a965 merged revision(s) commit:2dd46bb82ffc4dff01d7ea70922f0e407acafb4e. ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-109023 * Author: kddnewton (Kevin Newton) * Status: Closed * Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/

Issue #20468 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE to 3.1: REQUIRED, 3.2: DONE, 3.3: DONE ruby_3_2 commit:c10c73fd16f1b7c9b658afee2b1b53ecfaed4fa4 merged revision(s) commit:2dd46bb82ffc4dff01d7ea70922f0e407acafb4e. ---------------------------------------- Bug #20468: Segfault on safe navigation in for target https://bugs.ruby-lang.org/issues/20468#change-109175 * Author: kddnewton (Kevin Newton) * Status: Closed * Backport: 3.1: REQUIRED, 3.2: DONE, 3.3: DONE ---------------------------------------- ```ruby for foo&.bar in []; end ``` -- https://bugs.ruby-lang.org/
participants (6)
-
Eregon (Benoit Daloze)
-
k0kubun (Takashi Kokubun)
-
kddnewton (Kevin Newton)
-
nagachika (Tomoyuki Chikanaga)
-
nobu (Nobuyoshi Nakada)
-
zverok (Victor Shepelev)