Bug #14279
closedModifying splat argument causes segmentation fault
Description
Using Docker Ruby images ruby:2.2 through ruby:rc as of 2018-01-03, this little bit of code causes a segmentation fault:
class A
def x(*args)
args = 13
super
end
end
A.new.x
I'm not sure what the behavior of super ought to be here, and it doesn't seem to be addressed by The Ruby Spec Suite, but with Ruby 2.1 (Docker ruby:2.1) this causes a "no superclass method" exception rather than crashing the interpreter. I'm guessing this has to do with the optimization in https://bugs.ruby-lang.org/issues/10440
Updated by Eregon (Benoit Daloze) almost 7 years ago
I think something like a TypeError should be raised in such a case.
Updated by ko1 (Koichi Sasada) almost 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r61603.
check array for zsuper. [Bug #14279]
-
compile.c (iseq_compile_each0): for zsuper (NODE_ZSUPER), we need to check
given argument is Array or not. -
test/ruby/test_super.rb: add a test for this bug.
Updated by ko1 (Koichi Sasada) almost 7 years ago
I think something like a TypeError should be raised in such a case.
a = 13
p(*a) #=> 13
So that this case is similar to super(13)
.
Ruby 2.2 to 2.5 have same issue.
Thank you for your report.
Updated by nagachika (Tomoyuki Chikanaga) almost 7 years ago
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED
Though I cannot reproduce SEGV on my box with any version of ruby (2.2.6, 2.4.6, 2.4.3, 2.5.0), I believe reporter's and ko1's statement and set Backport field. :p
Updated by Eregon (Benoit Daloze) almost 7 years ago
nagachika (Tomoyuki Chikanaga) wrote:
Though I cannot reproduce SEGV on my box with any version of ruby (2.2.6, 2.4.6, 2.4.3, 2.5.0), I believe reporter's and ko1's statement and set Backport field. :p
I could reproduce on 2.2 and 2.5.0 fwiw.
Updated by naruse (Yui NARUSE) over 6 years ago
- Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE
ruby_2_5 r62420 merged revision(s) 61603.
Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago
- Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE to 2.3: REQUIRED, 2.4: DONE, 2.5: DONE
ruby_2_4 r62868 merged revision(s) 61603.
Updated by usa (Usaku NAKAMURA) over 6 years ago
- Backport changed from 2.3: REQUIRED, 2.4: DONE, 2.5: DONE to 2.3: DONE, 2.4: DONE, 2.5: DONE
ruby_2_3 r62944 merged revision(s) 61603.