Project

General

Profile

Actions

Bug #13015

closed

Segfault when using super and underscore parameters

Added by justcolin (Colin Fulton) almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-11-15 trunk 56793) [x86_64-darwin15]
[ruby-core:78536]

Description

Having multiple parameters named _ in a method works fine until you try to use the super keyword, at which point a segfault occurs. The use case where I ran into this was when I needed to create a child class which extends the initializer of the parent by adding an additional named argument.

class ParentClass
  def initialize a, b, c:
    # It doesn't matter what's in here
  end
end

class ChildClass < ParentClass
  def initialize *_, d:, **_
    super
  end
end

ChildClass.new(1, 2, c: 3, d: 4) # => this creates a segfault

I have seen this bug in 2.3.0 as well as 2.4.0dev. Here is the crash report from running the above code in irb:

(irb):9: [BUG] Segmentation fault at 0x00000000000013
ruby 2.4.0dev (2016-11-15 trunk 56793) [x86_64-darwin15]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:                    
     * ~/Library/Logs/CrashReporter                                         
     * /Library/Logs/CrashReporter                                          
     * ~/Library/Logs/DiagnosticReports                                     
     * /Library/Logs/DiagnosticReports                                      
   for more details.                                                        
Don't forget to include the above Crash Report log file in bug reports.     

-- Control frame information -----------------------------------------------
c:0021 p:0022 s:0119 e:000109 METHOD (irb):9 [FINISH]
c:0020 p:---- s:0102 e:000101 CFUNC  :new
c:0019 p:0019 s:0095 e:000094 EVAL   (irb):13 [FINISH]
c:0018 p:---- s:0092 e:000091 CFUNC  :eval
c:0017 p:0025 s:0084 e:000083 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/workspace.rb:87
c:0016 p:0027 s:0076 e:000074 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/context.rb:380
c:0015 p:0024 s:0069 e:000068 BLOCK  /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:493
c:0014 p:0041 s:0060 e:000059 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:627
c:0013 p:0011 s:0054 e:000053 BLOCK  /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:490
c:0012 p:0128 s:0049 e:000048 BLOCK  /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:246 [FINISH]
c:0011 p:---- s:0045 e:000044 CFUNC  :loop
c:0010 p:0009 s:0041 e:000040 BLOCK  /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:232 [FINISH]
c:0009 p:---- s:0038 e:000037 CFUNC  :catch
c:0008 p:0018 s:0033 e:000032 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:231
c:0007 p:0037 s:0029 E:000850 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:489
c:0006 p:0008 s:0025 e:000024 BLOCK  /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:430 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :catch
c:0004 p:0075 s:0017 E:002628 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:429
c:0003 p:0118 s:0012 e:000011 METHOD /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:385
c:0002 p:0023 s:0006 e:000005 EVAL   /Users/admin/.rbenv/versions/2.4.0-dev/bin/irb:11 [FINISH]
c:0001 p:0000 s:0003 E:0009a0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/admin/.rbenv/versions/2.4.0-dev/bin/irb:11:in `<main>'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:385:in `start'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:429:in `run'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:429:in `catch'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:430:in `block in run'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:489:in `eval_input'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:231:in `catch'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:232:in `loop'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:490:in `block in eval_input'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:627:in `signal_status'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb:493:in `block (2 levels) in eval_input'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/context.rb:380:in `evaluate'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/workspace.rb:87:in `evaluate'
/Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/workspace.rb:87:in `eval'
(irb):13:in `irb_binding'
(irb):13:in `new'
(irb):9:in `initialize'

-- Machine register context ------------------------------------------------
 rax: 0x0000000101b8ea50 rbx: 0x00007fcc6c82dfd0 rcx: 0x0000000000000007
 rdx: 0x0000000000000008 rdi: 0x0000000000000003 rsi: 0x000000000097c10c
 rbp: 0x00007fff5e2c5f00 rsp: 0x00007fff5e2c5eb0  r8: 0x00007fcc6d032f28
  r9: 0x0000000101af2010 r10: 0x00000000000000a6 r11: 0x0000000101f8bc10
 r12: 0x0000000000000005 r13: 0x0000000000000002 r14: 0x0000000000000008
 r15: 0x000000000097c10c rip: 0x00000001019c4a86 rfl: 0x0000000000010206

-- C level backtrace information -------------------------------------------
0   ruby                                0x0000000101b01764 rb_vm_bugreport + 388
1   ruby                                0x000000010199d49a rb_bug_context + 490
2   ruby                                0x0000000101a7bc23 sigsegv + 83
3   libsystem_platform.dylib            0x00007fff9757352a _sigtramp + 26
4   ruby                                0x00000001019c4a86 rb_hash_aset + 150
5   ruby                                0x0000000101af2072 m_core_hash_merge_ptr + 98
6   ruby                                0x0000000101af45de vm_call_cfunc + 302
7   ruby                                0x0000000101adcbd0 vm_exec_core + 13344
8   ruby                                0x0000000101aeeb44 vm_exec + 116
9   ruby                                0x0000000101ae5fce rb_funcallv + 350
10  ruby                                0x0000000101a05569 rb_class_new_instance + 41
11  ruby                                0x0000000101af45de vm_call_cfunc + 302
12  ruby                                0x0000000101adcbd0 vm_exec_core + 13344
13  ruby                                0x0000000101aeeb44 vm_exec + 116
14  ruby                                0x0000000101afda0c eval_string_with_cref + 1260
15  ruby                                0x0000000101aea072 rb_f_eval + 306
16  ruby                                0x0000000101af45de vm_call_cfunc + 302
17  ruby                                0x0000000101adcbd0 vm_exec_core + 13344
18  ruby                                0x0000000101aeeb44 vm_exec + 116
19  ruby                                0x0000000101ae984f rb_yield_0 + 303
20  ruby                                0x0000000101afdce9 loop_i + 25
21  ruby                                0x00000001019a7136 rb_rescue2 + 278
22  ruby                                0x0000000101af45de vm_call_cfunc + 302
23  ruby                                0x0000000101adc41d vm_exec_core + 11373
24  ruby                                0x0000000101aeeb44 vm_exec + 116
25  ruby                                0x0000000101ae984f rb_yield_0 + 303
26  ruby                                0x0000000101afdcaa catch_i + 26
27  ruby                                0x0000000101aeb4c1 vm_catch_protect + 145
28  ruby                                0x0000000101aebca2 rb_f_catch + 66
29  ruby                                0x0000000101af45de vm_call_cfunc + 302
30  ruby                                0x0000000101adc41d vm_exec_core + 11373
31  ruby                                0x0000000101aeeb44 vm_exec + 116
32  ruby                                0x0000000101ae984f rb_yield_0 + 303
33  ruby                                0x0000000101afdcaa catch_i + 26
34  ruby                                0x0000000101aeb4c1 vm_catch_protect + 145
35  ruby                                0x0000000101aebca2 rb_f_catch + 66
36  ruby                                0x0000000101af45de vm_call_cfunc + 302
37  ruby                                0x0000000101adc41d vm_exec_core + 11373
38  ruby                                0x0000000101aeeb44 vm_exec + 116
39  ruby                                0x00000001019a6458 ruby_exec_internal + 136
40  ruby                                0x00000001019a6376 ruby_run_node + 54
41  ruby                                0x00000001019382ff main + 79

-- Other runtime information -----------------------------------------------

* Loaded script: irb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/x86_64-darwin15/enc/encdb.bundle
    5 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/x86_64-darwin15/enc/trans/transdb.bundle
    6 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/unicode_normalize.rb
    7 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/x86_64-darwin15/rbconfig.rb
    8 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/compatibility.rb
    9 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/defaults.rb
   10 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/deprecate.rb
   11 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/errors.rb
   12 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/version.rb
   13 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/requirement.rb
   14 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/platform.rb
   15 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/basic_specification.rb
   16 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/stub_specification.rb
   17 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/util/list.rb
   18 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/x86_64-darwin15/stringio.bundle
   19 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/specification.rb
   20 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/exceptions.rb
   21 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/dependency.rb
   22 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb
   23 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/monitor.rb
   24 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb
   25 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems.rb
   26 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/rubygems/path_support.rb
   27 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/e2mmap.rb
   28 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/init.rb
   29 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/workspace.rb
   30 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/inspector.rb
   31 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/context.rb
   32 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/extend-command.rb
   33 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/output-method.rb
   34 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/notifier.rb
   35 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/slex.rb
   36 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-token.rb
   37 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/ruby-lex.rb
   38 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/src_encoding.rb
   39 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/magic-file.rb
   40 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/x86_64-darwin15/readline.bundle
   41 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/input-method.rb
   42 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb/locale.rb
   43 /Users/admin/.rbenv/versions/2.4.0-dev/lib/ruby/2.4.0/irb.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0