Project

General

Profile

Bug #14421

Updated by rusterholz (Andy Rusterholz) almost 7 years ago

The line of code below causes a segfault on 2.5.0. 

 The segfault is not limited to the String class used in the example; it can be reproduced with any class with at least one instance_method. More generally, it can be reproduced any time `super_method` is called on a Method which was formed by (validly) calling `bind` on an UnboundMethod. 

 ~~~ ruby 
 $ ruby -e 'String.instance_method(:length).bind(String.new).super_method' 
 -e:1: [BUG] Segmentation fault at 0x0000000000000018 
 ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17] 

 -- Crash Report log information -------------------------------------------- 
    See Crash Report log file under the one of following: 
      * ~/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:0003 p:---- s:0010 e:000009 CFUNC    :super_method 
 c:0002 p:0028 s:0006 e:000005 EVAL     -e:1 [FINISH] 
 c:0001 p:0000 s:0003 E:001570 (none) [FINISH] 

 -- Ruby level backtrace information ---------------------------------------- 
 -e:1:in `<main>' 
 -e:1:in `super_method' 

 -- Machine register context ------------------------------------------------ 
  rax: 0x0000000000000000 rbx: 0x00007fc51f43e1e0 rcx: 0x0000000108308730 
  rdx: 0x0000000000000000 rdi: 0x00007fc52106fd18 rsi: 0x0000000108308730 
  rbp: 0x00007ffee7b78f80 rsp: 0x00007ffee7b78f40    r8: 0x00007fc51f4623b8 
   r9: 0x0000000108543fa0 r10: 0x00007fc51f5070e8 r11: 0x0000000000000016 
  r12: 0x0000000000000000 r13: 0x00007fc51f541860 r14: 0x0000000000000000 
  r15: 0x00007fc52106fd18 rip: 0x000000010819a2eb rfl: 0x0000000000010246 

 -- C level backtrace information ------------------------------------------- 
 0     libruby.2.5.dylib                     0x0000000108274d17 rb_vm_bugreport + 135 
 1     libruby.2.5.dylib                     0x00000001080f9988 rb_bug_context + 472 
 2     libruby.2.5.dylib                     0x00000001081e9161 sigsegv + 81 
 3     libsystem_platform.dylib              0x00007fff7e2c0f5a _sigtramp + 26 
 4     libruby.2.5.dylib                     0x000000010819a2eb method_super_method + 43 
 5     libruby.2.5.dylib                     0x00000001082681fb vm_call_cfunc + 283 
 6     libruby.2.5.dylib                     0x0000000108251954 vm_exec_core + 12196 
 7     libruby.2.5.dylib                     0x0000000108262ace vm_exec + 142 
 8     libruby.2.5.dylib                     0x0000000108103501 ruby_exec_internal + 177 
 9     libruby.2.5.dylib                     0x00000001081033f8 ruby_run_node + 56 
 10    ruby                                  0x0000000108086f2f main + 79 

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

 * Loaded script: -e 

 * Loaded features: 

     0 enumerator.so 
     1 thread.rb 
     2 rational.so 
     3 complex.so 
     4 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/x86_64-darwin17/enc/encdb.bundle 
     5 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/x86_64-darwin17/enc/trans/transdb.bundle 
     6 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/x86_64-darwin17/rbconfig.rb 
     7 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/compatibility.rb 
     8 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/defaults.rb 
     9 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/deprecate.rb 
    10 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/errors.rb 
    11 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/version.rb 
    12 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/requirement.rb 
    13 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/platform.rb 
    14 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/basic_specification.rb 
    15 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/stub_specification.rb 
    16 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/util/list.rb 
    17 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/x86_64-darwin17/stringio.bundle 
    18 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/specification.rb 
    19 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/exceptions.rb 
    20 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/dependency.rb 
    21 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_gem.rb 
    22 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/monitor.rb 
    23 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb 
    24 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems.rb 
    25 /Users/rusterholz/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/path_support.rb 

 ~~~ 

 **Expected Results:** Given that `String.new.method(:length).super_method` correctly returns nil, I would expect `String.instance_method(:length).bind(String.new).super_method` to also return nil.

Back