[ruby-core:111811] [Ruby master Bug#19339] Defining ivar on special constants with @ syntax causes segv

Issue #19339 has been reported by luke-gru (Luke Gruber). ---------------------------------------- Bug #19339: Defining ivar on special constants with @ syntax causes segv https://bugs.ruby-lang.org/issues/19339 * Author: luke-gru (Luke Gruber) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- ```ruby 1.instance_eval do @a = 1 end ``` There's a missing check at the top of vm_setivar_fastpath, should be: ```c if (UNLIKELY(RB_SPECIAL_CONST_P(obj))) { // example code: 1.instance_eval { @a = 1 } rb_check_frozen(obj); // raise FrozenError, because it's always frozen return Qundef; } ``` -- https://bugs.ruby-lang.org/

Issue #19339 has been updated by peterzhu2118 (Peter Zhu). Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED Thank you for reporting this bug. I opened a PR with the fix here: https://github.com/ruby/ruby/pull/7129 ---------------------------------------- Bug #19339: Defining ivar on special constants with @ syntax causes segv https://bugs.ruby-lang.org/issues/19339#change-101247 * Author: luke-gru (Luke Gruber) * Status: Open * Priority: Normal * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED ---------------------------------------- ```ruby 1.instance_eval do @a = 1 end ``` There's a missing check at the top of vm_setivar_fastpath, should be: ```c if (UNLIKELY(RB_SPECIAL_CONST_P(obj))) { // example code: 1.instance_eval { @a = 1 } rb_check_frozen(obj); // raise FrozenError, because it's always frozen return Qundef; } ``` -- https://bugs.ruby-lang.org/

Issue #19339 has been updated by naruse (Yui NARUSE). Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ruby_3_2 c0df0a85dec77a09308caddb1e1efd4d38fbf7b8 merged revision(s) ed6fbb79e19bf401db0e85447fee955fd10a25c7. ---------------------------------------- Bug #19339: Defining ivar on special constants with @ syntax causes segv https://bugs.ruby-lang.org/issues/19339#change-101433 * Author: luke-gru (Luke Gruber) * Status: Closed * Priority: Normal * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ---------------------------------------- ```ruby 1.instance_eval do @a = 1 end ``` There's a missing check at the top of vm_setivar_fastpath, should be: ```c if (UNLIKELY(RB_SPECIAL_CONST_P(obj))) { // example code: 1.instance_eval { @a = 1 } rb_check_frozen(obj); // raise FrozenError, because it's always frozen return Qundef; } ``` -- https://bugs.ruby-lang.org/
participants (3)
-
luke-gru (Luke Gruber)
-
naruse (Yui NARUSE)
-
peterzhu2118 (Peter Zhu)