Project

General

Profile

Bug #14279

Modifying splat argument causes segmentation fault

Added by coreycerovsek (Corey Cerovsek) almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0rc1 (2017-12-14 trunk 61243) [x86_64-linux]
[ruby-core:84622]

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

Associated revisions

Revision 44936575
Added by ko1 (Koichi Sasada) almost 2 years ago

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61603
Added by ko1 (Koichi Sasada) almost 2 years ago

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.

Revision 61603
Added by ko1 (Koichi Sasada) almost 2 years ago

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.

Revision 53859b79
Added by naruse (Yui NARUSE) almost 2 years ago

merge revision(s) 61603: [Backport #14279]

    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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62420
Added by naruse (Yui NARUSE) almost 2 years ago

merge revision(s) 61603: [Backport #14279]

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.

Revision 1e189822
Added by nagachika (Tomoyuki Chikanaga) over 1 year ago

merge revision(s) 61603: [Backport #14279]

    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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62868
Added by nagachika (Tomoyuki Chikanaga) over 1 year ago

merge revision(s) 61603: [Backport #14279]

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.

Revision 0b46bbf7
Added by usa (Usaku NAKAMURA) over 1 year ago

merge revision(s) 61603: [Backport #14279]

    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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62944
Added by usa (Usaku NAKAMURA) over 1 year ago

merge revision(s) 61603: [Backport #14279]

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.

History

Updated by Eregon (Benoit Daloze) almost 2 years ago

I think something like a TypeError should be raised in such a case.

#2

Updated by ko1 (Koichi Sasada) almost 2 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 2 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 2 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 2 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) almost 2 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 1 year 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 1 year 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.

Also available in: Atom PDF