rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 553 forks source link

Segfault on Ruby 2.2.0 after upgrading to Thor 1.0.1 from 0.20.3 #705

Closed sentience closed 4 years ago

sentience commented 4 years ago

MRI 2.2.0p0 on Ubuntu 18.04 LTS (GNU/Linux 4.15.0-1009-aws x86_64).

This is 100% reproducible on my configuration. I'm about to roll back to 0.20.3 to get my infrastructure working again.

/opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor.rb:503: [BUG] Segmentation fault at 0x00000000000000
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0009 p:0042 s:0034 e:000031 CLASS  /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor.rb:503
c:0008 p:0025 s:0030 e:000029 TOP    /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor.rb:4 [FINISH]
c:0007 p:---- s:0028 e:000027 CFUNC  :require
c:0006 p:0170 s:0024 e:000023 METHOD /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0005 p:0015 s:0014 e:000013 TOP    /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/eye-0.10.0/lib/eye/cli.rb:4 [FINISH]
c:0004 p:0059 s:0012 e:000011 TOP    /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/eye-0.10.0/bin/eye:5 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC  :load
c:0002 p:0135 s:0006 E:000440 EVAL   /opt/rbenv/versions/2.2.0/bin/eye:23 [FINISH]
c:0001 p:0000 s:0002 E:002290 TOP    [FINISH]

-- Ruby level backtrace information ----------------------------------------
/opt/rbenv/versions/2.2.0/bin/eye:23:in `<main>'
/opt/rbenv/versions/2.2.0/bin/eye:23:in `load'
/opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/eye-0.10.0/bin/eye:5:in `<top (required)>'
/opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/eye-0.10.0/lib/eye/cli.rb:4:in `<top (required)>'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
/opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor.rb:4:in `<top (required)>'
/opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor.rb:503:in `<class:Thor>'

-- Machine register context ------------------------------------------------
 RIP: 0x00005624aebf5254 RBP: 0x00007ffd260fbc80 RSP: 0x00007ffd260fbba0
 RAX: 0x0000000000000001 RBX: 0x00007effab14f120 RCX: 0x00007effab14f118
 RDX: 0x00007effab14f118 RDI: 0x0000000000000000 RSI: 0x00005624af380020
  R8: 0x00005624af44ea48  R9: 0x0000000000000000 R10: 0x0000000000000000
 R11: 0x0000000000000000 R12: 0x0000000000000003 R13: 0x0000000000000001
 R14: 0x00005624af4f1fd0 R15: 0x0000000000000000 EFL: 0x0000000000010293

-- C level backtrace information -------------------------------------------
/opt/rbenv/versions/2.2.0/bin/ruby(rb_vm_bugreport+0x661) [0x5624aed21251] vm_dump.c:693
/opt/rbenv/versions/2.2.0/bin/ruby(rb_bug_context+0xc8) [0x5624aed916d8] error.c:389
/opt/rbenv/versions/2.2.0/bin/ruby(sigsegv+0x52) [0x5624aec93372] signal.c:878
/lib/x86_64-linux-gnu/libpthread.so.0 [0x7effaae28890]
/opt/rbenv/versions/2.2.0/bin/ruby(rb_hash_dup+0x4) [0x5624aebf5254] hash.c:331
/opt/rbenv/versions/2.2.0/bin/ruby(setup_parameters_complex+0x62e) [0x5624aed18d9e] vm_args.c:461
/opt/rbenv/versions/2.2.0/bin/ruby(vm_call_iseq_setup+0x5aa) [0x5624aed19f8a] vm_insnhelper.c:1098
/opt/rbenv/versions/2.2.0/bin/ruby(vm_call_method+0xfe) [0x5624aed1b08e] vm_insnhelper.c:1651
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec_core+0x542) [0x5624aed0cc72] insns.def:1054
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec+0x71) [0x5624aed12321] vm.c:1407
/opt/rbenv/versions/2.2.0/bin/ruby(rb_iseq_eval+0x194) [0x5624aed1e364] vm.c:1664
/opt/rbenv/versions/2.2.0/bin/ruby(rb_load_internal0+0x128) [0x5624aebc88c8] load.c:614
/opt/rbenv/versions/2.2.0/bin/ruby(rb_require_internal+0x786) [0x5624aebcb196] load.c:643
/opt/rbenv/versions/2.2.0/bin/ruby(rb_f_require+0x13) [0x5624aebcb2d3] load.c:1052
/opt/rbenv/versions/2.2.0/bin/ruby(vm_call_cfunc+0x118) [0x5624aed09358] vm_insnhelper.c:1360
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec_core+0x542) [0x5624aed0cc72] insns.def:1054
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec+0x71) [0x5624aed12321] vm.c:1407
/opt/rbenv/versions/2.2.0/bin/ruby(rb_iseq_eval+0x194) [0x5624aed1e364] vm.c:1664
/opt/rbenv/versions/2.2.0/bin/ruby(rb_load_internal0+0x128) [0x5624aebc88c8] load.c:614
/opt/rbenv/versions/2.2.0/bin/ruby(rb_require_internal+0x786) [0x5624aebcb196] load.c:643
/opt/rbenv/versions/2.2.0/bin/ruby(rb_require_safe+0x9) [0x5624aebcb429] load.c:1052
/opt/rbenv/versions/2.2.0/bin/ruby(rb_protect+0x1aa) [0x5624aebc721a] eval.c:876
/opt/rbenv/versions/2.2.0/bin/ruby(rb_autoload_load+0x1c6) [0x5624aece5dd6] variable.c:1802
/opt/rbenv/versions/2.2.0/bin/ruby(rb_public_const_get_from+0xed) [0x5624aece6b0d] variable.c:1862
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec_core+0x2965) [0x5624aed0f095] vm_insnhelper.c:420
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec+0x71) [0x5624aed12321] vm.c:1407
/opt/rbenv/versions/2.2.0/bin/ruby(rb_iseq_eval+0x194) [0x5624aed1e364] vm.c:1664
/opt/rbenv/versions/2.2.0/bin/ruby(rb_load_internal0+0x128) [0x5624aebc88c8] load.c:614
/opt/rbenv/versions/2.2.0/bin/ruby(rb_f_load+0x7f) [0x5624aebc8bbf] load.c:643
/opt/rbenv/versions/2.2.0/bin/ruby(vm_call_cfunc+0x118) [0x5624aed09358] vm_insnhelper.c:1360
/opt/rbenv/versions/2.2.0/bin/ruby(vm_call_method+0x11e) [0x5624aed1b0ae] vm_insnhelper.c:1656
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec_core+0x542) [0x5624aed0cc72] insns.def:1054
/opt/rbenv/versions/2.2.0/bin/ruby(vm_exec+0x71) [0x5624aed12321] vm.c:1407
/opt/rbenv/versions/2.2.0/bin/ruby(rb_iseq_eval_main+0x1e3) [0x5624aed1e5c3] vm.c:1677
/opt/rbenv/versions/2.2.0/bin/ruby(ruby_exec_internal+0xb9) [0x5624aebc2b29] eval.c:252
/opt/rbenv/versions/2.2.0/bin/ruby(ruby_run_node+0x2f) [0x5624aebc674f] eval.c:317
/opt/rbenv/versions/2.2.0/bin/ruby(main+0x4b) [0x5624aebc264b] parse.y:8763

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

* Loaded script: /opt/rbenv/versions/2.2.0/bin/eye

* Loaded features:

    0 enumerator.so
    1 rational.so
    2 complex.so
    3 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so
    4 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so
    5 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/unicode_normalize.rb
    6 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/rbconfig.rb
    7 thread.rb
    8 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/thread.so
    9 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/compatibility.rb
   10 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/defaults.rb
   11 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/deprecate.rb
   12 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/errors.rb
   13 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/version.rb
   14 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/requirement.rb
   15 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/platform.rb
   16 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb
   17 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/stub_specification.rb
   18 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/util/stringio.rb
   19 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/specification.rb
   20 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/exceptions.rb
   21 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
   22 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb
   23 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
   24 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems.rb
   25 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/dependency.rb
   26 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/path_support.rb
   27 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/eye-0.10.0/lib/eye.rb
   28 /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/set.rb
   29 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/command.rb
   30 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/core_ext/hash_with_indifferent_access.rb
   31 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/error.rb
   32 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/invocation.rb
   33 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/nested_context.rb
   34 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/parser/argument.rb
   35 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/parser/arguments.rb
   36 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/parser/option.rb
   37 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/parser/options.rb
   38 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/parser.rb
   39 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/shell.rb
   40 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/line_editor/basic.rb
   41 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/line_editor/readline.rb
   42 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/line_editor.rb
   43 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/util.rb
   44 /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-1.0.1/lib/thor/base.rb

* Process memory map:

5624aeba0000-5624aee73000 r-xp 00000000 ca:01 294133                     /opt/rbenv/versions/2.2.0/bin/ruby
5624af072000-5624af077000 r--p 002d2000 ca:01 294133                     /opt/rbenv/versions/2.2.0/bin/ruby
5624af077000-5624af078000 rw-p 002d7000 ca:01 294133                     /opt/rbenv/versions/2.2.0/bin/ruby
5624af078000-5624af088000 rw-p 00000000 00:00 0
5624af123000-5624af653000 rw-p 00000000 00:00 0                          [heap]
7effa8aa9000-7effa8c99000 r--s 00000000 ca:01 2075                       /lib/x86_64-linux-gnu/libc-2.27.so
7effa8c99000-7effa9a28000 r--s 00000000 ca:01 294133                     /opt/rbenv/versions/2.2.0/bin/ruby
7effa9a28000-7effa9a3f000 r-xp 00000000 ca:01 2062                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7effa9a3f000-7effa9c3e000 ---p 00017000 ca:01 2062                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7effa9c3e000-7effa9c3f000 r--p 00016000 ca:01 2062                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7effa9c3f000-7effa9c40000 rw-p 00017000 ca:01 2062                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7effa9c40000-7effa9c43000 r-xp 00000000 ca:01 294979                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/thread.so
7effa9c43000-7effa9e43000 ---p 00003000 ca:01 294979                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/thread.so
7effa9e43000-7effa9e44000 r--p 00003000 ca:01 294979                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/thread.so
7effa9e44000-7effa9e45000 rw-p 00004000 ca:01 294979                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/thread.so
7effa9e45000-7effa9e47000 r-xp 00000000 ca:01 295029                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so
7effa9e47000-7effaa046000 ---p 00002000 ca:01 295029                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so
7effaa046000-7effaa047000 r--p 00001000 ca:01 295029                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so
7effaa047000-7effaa048000 rw-p 00002000 ca:01 295029                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so
7effaa048000-7effaa04a000 r-xp 00000000 ca:01 295019                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so
7effaa04a000-7effaa249000 ---p 00002000 ca:01 295019                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so
7effaa249000-7effaa24a000 r--p 00001000 ca:01 295019                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so
7effaa24a000-7effaa24b000 rw-p 00002000 ca:01 295019                     /opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so
7effaa24b000-7effaa432000 r-xp 00000000 ca:01 2075                       /lib/x86_64-linux-gnu/libc-2.27.so
7effaa432000-7effaa632000 ---p 001e7000 ca:01 2075                       /lib/x86_64-linux-gnu/libc-2.27.so
7effaa632000-7effaa636000 r--p 001e7000 ca:01 2075                       /lib/x86_64-linux-gnu/libc-2.27.so
7effaa636000-7effaa638000 rw-p 001eb000 ca:01 2075                       /lib/x86_64-linux-gnu/libc-2.27.so
7effaa638000-7effaa63c000 rw-p 00000000 00:00 0
7effaa63c000-7effaa7d9000 r-xp 00000000 ca:01 2079                       /lib/x86_64-linux-gnu/libm-2.27.so
7effaa7d9000-7effaa9d8000 ---p 0019d000 ca:01 2079                       /lib/x86_64-linux-gnu/libm-2.27.so
7effaa9d8000-7effaa9d9000 r--p 0019c000 ca:01 2079                       /lib/x86_64-linux-gnu/libm-2.27.so
7effaa9d9000-7effaa9da000 rw-p 0019d000 ca:01 2079                       /lib/x86_64-linux-gnu/libm-2.27.so
7effaa9da000-7effaa9e3000 r-xp 00000000 ca:01 2077                       /lib/x86_64-linux-gnu/libcrypt-2.27.so
7effaa9e3000-7effaabe2000 ---p 00009000 ca:01 2077                       /lib/x86_64-linux-gnu/libcrypt-2.27.so
7effaabe2000-7effaabe3000 r--p 00008000 ca:01 2077                       /lib/x86_64-linux-gnu/libcrypt-2.27.so
7effaabe3000-7effaabe4000 rw-p 00009000 ca:01 2077                       /lib/x86_64-linux-gnu/libcrypt-2.27.so
7effaabe4000-7effaac12000 rw-p 00000000 00:00 0
7effaac12000-7effaac15000 r-xp 00000000 ca:01 2078                       /lib/x86_64-linux-gnu/libdl-2.27.so
7effaac15000-7effaae14000 ---p 00003000 ca:01 2078                       /lib/x86_64-linux-gnu/libdl-2.27.so
7effaae14000-7effaae15000 r--p 00002000 ca:01 2078                       /lib/x86_64-linux-gnu/libdl-2.27.so
7effaae15000-7effaae16000 rw-p 00003000 ca:01 2078                       /lib/x86_64-linux-gnu/libdl-2.27.so
7effaae16000-7effaae30000 r-xp 00000000 ca:01 2169                       /lib/x86_64-linux-gnu/libpthread-2.27.so
7effaae30000-7effab02f000 ---p 0001a000 ca:01 2169                       /lib/x86_64-linux-gnu/libpthread-2.27.so
7effab02f000-7effab030000 r--p 00019000 ca:01 2169                       /lib/x86_64-linux-gnu/libpthread-2.27.so
7effab030000-7effab031000 rw-p 0001a000 ca:01 2169                       /lib/x86_64-linux-gnu/libpthread-2.27.so
7effab031000-7effab035000 rw-p 00000000 00:00 0
7effab035000-7effab05c000 r-xp 00000000 ca:01 2071                       /lib/x86_64-linux-gnu/ld-2.27.so
7effab12b000-7effab14f000 r--s 00000000 ca:01 2169                       /lib/x86_64-linux-gnu/libpthread-2.27.so
7effab14f000-7effab254000 rw-p 00000000 00:00 0
7effab257000-7effab258000 ---p 00000000 00:00 0
7effab258000-7effab25c000 rw-p 00000000 00:00 0
7effab25c000-7effab25d000 r--p 00027000 ca:01 2071                       /lib/x86_64-linux-gnu/ld-2.27.so
7effab25d000-7effab25e000 rw-p 00028000 ca:01 2071                       /lib/x86_64-linux-gnu/ld-2.27.so
7effab25e000-7effab25f000 rw-p 00000000 00:00 0
7ffd260df000-7ffd26100000 rw-p 00000000 00:00 0                          [stack]
7ffd26165000-7ffd26168000 r--p 00000000 00:00 0                          [vvar]
7ffd26168000-7ffd2616a000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

[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
rafaelfranca commented 4 years ago

It seems you found a bug in Ruby, not in Thor. Thor has no C extension so it can't cause segfaults. The segfault is happening on this line https://github.com/erikhuda/thor/blob/fb625b223465692a9d8a88cc2a483e126f1a8978/lib/thor.rb#L503. It is a regular method call, so there is no way it is Thor fault.

Thank you for the report.