Project

General

Profile

Actions

Bug #13313

closed

Segmentation fault when calling Thread.new with Symbol proc shorthand

Added by toy (Ivan Kuchin) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
[ruby-core:80147]

Description

Both following lines produce "1" in ruby versions before 2.4.0, but second one causes Segmentation fault in ruby 2.4.0 and head (ruby 2.5.0dev (2017-03-13 trunk 57944) [x86_64-linux]).

p Thread.new(1){ |x| x.to_s }.value # => "1"
p Thread.new(1, &:to_s).value # Segmentation fault

Output for 2.4.0 (for this and other versions on travis-ci):

[BUG] Segmentation fault at 0x00000000000000
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0001 p:---- s:0003 e:000002 (none) [FINISH]


-- Machine register context ------------------------------------------------
 RIP: 0x00007f2b17f58390 RBP: 0x0000000000000000 RSP: 0x00007f2b16496c68
 RAX: 0x00000000015dd180 RBX: 0x00000000015d8910 RCX: 0x00007f2b16496e20
 RDX: 0x0000000000000002 RDI: 0x0000000000000000 RSI: 0x00000000015d8910
  R8: 0x000000000123af30  R9: 0x0000000000000ce7 R10: 0x00007f2b164969e0
 R11: 0x00007f2b17eadbe0 R12: 0x00007fffbf6e9b80 R13: 0x00007f2b164979c0
 R14: 0x0000000000000000 R15: 0x0000000000000003 EFL: 0x0000000000010246

-- C level backtrace information -------------------------------------------
/home/travis/.rvm/rubies/ruby-2.4.0/bin/../lib/libruby.so.2.4(rb_vm_bugreport+0x5c7) [0x7f2b17f75d47] vm_dump.c:679
/home/travis/.rvm/rubies/ruby-2.4.0/bin/../lib/libruby.so.2.4(rb_bug_context+0xd7) [0x7f2b17e1f3b7] error.c:426
/home/travis/.rvm/rubies/ruby-2.4.0/bin/../lib/libruby.so.2.4(sigsegv+0x3e) [0x7f2b17ef9c1e] signal.c:907
/lib/x86_64-linux-gnu/libc.so.6 [0x7f2b17a060b0]
[0x7f2b17f58390]
/home/travis/.rvm/rubies/ruby-2.4.0/bin/../lib/libruby.so.2.4(thread_start_func_2+0x565) [0x7f2b17f30015] thread.c:585
/home/travis/.rvm/rubies/ruby-2.4.0/bin/../lib/libruby.so.2.4(thread_start_func_1+0xd1) [0x7f2b17f30551] thread_pthread.c:887
/lib/x86_64-linux-gnu/libpthread.so.0(start_thread+0xda) [0x7f2b177bae9a]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f2b17ac336d]

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

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
    5 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
    6 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/unicode_normalize.rb
    7 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/rbconfig.rb
    8 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/compatibility.rb
    9 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/defaults.rb
   10 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/deprecate.rb
   11 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/errors.rb
   12 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/version.rb
   13 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/requirement.rb
   14 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/platform.rb
   15 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/basic_specification.rb
   16 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/stub_specification.rb
   17 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/util/list.rb
   18 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/stringio.so
   19 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb
   20 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/exceptions.rb
   21 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/dependency.rb
   22 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb
   23 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/monitor.rb
   24 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb
   25 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems.rb
   26 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/path_support.rb
   27 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/version.rb
   28 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/core_ext/name_error.rb
   29 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/levenshtein.rb
   30 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/jaro_winkler.rb
   31 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checker.rb
   32 /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/delegate.rb
   33 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   34 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   35 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   36 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   37 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/null_checker.rb
   38 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean/formatter.rb
   39 /home/travis/.rvm/gems/ruby-2.4.0@global/gems/did_you_mean-1.1.0/lib/did_you_mean.rb

* Process memory map:

00400000-00401000 r-xp 00000000 fc:09 34072                              /home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby
00600000-00601000 r--p 00000000 fc:09 34072                              /home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby
00601000-00602000 rw-p 00001000 fc:09 34072                              /home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby
0123a000-015eb000 rw-p 00000000 00:00 0                                  [heap]
7f2b10000000-7f2b10021000 rw-p 00000000 00:00 0 
7f2b10021000-7f2b14000000 ---p 00000000 00:00 0 
7f2b14987000-7f2b14b41000 r--s 00000000 fc:09 109174840                  /lib/x86_64-linux-gnu/libc-2.15.so
7f2b14b41000-7f2b16181000 r--s 00000000 fc:09 68248128                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/libruby.so.2.4.0
7f2b16181000-7f2b16196000 r-xp 00000000 fc:09 109052221                  /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2b16196000-7f2b16395000 ---p 00015000 fc:09 109052221                  /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2b16395000-7f2b16396000 r--p 00014000 fc:09 109052221                  /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2b16396000-7f2b16397000 rw-p 00015000 fc:09 109052221                  /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2b16397000-7f2b16398000 ---p 00000000 00:00 0 
7f2b16398000-7f2b16599000 rw-p 00000000 00:00 0 
7f2b16599000-7f2b165a1000 r-xp 00000000 fc:09 84390431                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f2b165a1000-7f2b167a0000 ---p 00008000 fc:09 84390431                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f2b167a0000-7f2b167a1000 r--p 00007000 fc:09 84390431                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f2b167a1000-7f2b167a2000 rw-p 00008000 fc:09 84390431                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f2b167a2000-7f2b167a4000 r-xp 00000000 fc:09 109052190                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f2b167a4000-7f2b169a4000 ---p 00002000 fc:09 109052190                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f2b169a4000-7f2b169a5000 r--p 00002000 fc:09 109052190                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f2b169a5000-7f2b169a6000 rw-p 00003000 fc:09 109052190                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f2b169a6000-7f2b169a8000 r-xp 00000000 fc:09 102038013                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f2b169a8000-7f2b16ba7000 ---p 00002000 fc:09 102038013                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f2b16ba7000-7f2b16ba8000 r--p 00001000 fc:09 102038013                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f2b16ba8000-7f2b16ba9000 rw-p 00002000 fc:09 102038013                  /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f2b16ba9000-7f2b16e72000 r--p 00000000 fc:09 50375529                   /usr/lib/locale/locale-archive
7f2b16e72000-7f2b16f6d000 r-xp 00000000 fc:09 109175105                  /lib/x86_64-linux-gnu/libm-2.15.so
7f2b16f6d000-7f2b1716c000 ---p 000fb000 fc:09 109175105                  /lib/x86_64-linux-gnu/libm-2.15.so
7f2b1716c000-7f2b1716d000 r--p 000fa000 fc:09 109175105                  /lib/x86_64-linux-gnu/libm-2.15.so
7f2b1716d000-7f2b1716e000 rw-p 000fb000 fc:09 109175105                  /lib/x86_64-linux-gnu/libm-2.15.so
7f2b1716e000-7f2b17177000 r-xp 00000000 fc:09 109174845                  /lib/x86_64-linux-gnu/libcrypt-2.15.so
7f2b17177000-7f2b17377000 ---p 00009000 fc:09 109174845                  /lib/x86_64-linux-gnu/libcrypt-2.15.so
7f2b17377000-7f2b17378000 r--p 00009000 fc:09 109174845                  /lib/x86_64-linux-gnu/libcrypt-2.15.so
7f2b17378000-7f2b17379000 rw-p 0000a000 fc:09 109174845                  /lib/x86_64-linux-gnu/libcrypt-2.15.so
7f2b17379000-7f2b173a7000 rw-p 00000000 00:00 0 
7f2b173a7000-7f2b173a9000 r-xp 00000000 fc:09 109174714                  /lib/x86_64-linux-gnu/libdl-2.15.so
7f2b173a9000-7f2b175a9000 ---p 00002000 fc:09 109174714                  /lib/x86_64-linux-gnu/libdl-2.15.so
7f2b175a9000-7f2b175aa000 r--p 00002000 fc:09 109174714                  /lib/x86_64-linux-gnu/libdl-2.15.so
7f2b175aa000-7f2b175ab000 rw-p 00003000 fc:09 109174714                  /lib/x86_64-linux-gnu/libdl-2.15.so
7f2b175ab000-7f2b175b2000 r-xp 00000000 fc:09 109174718                  /lib/x86_64-linux-gnu/librt-2.15.so
7f2b175b2000-7f2b177b1000 ---p 00007000 fc:09 109174718                  /lib/x86_64-linux-gnu/librt-2.15.so
7f2b177b1000-7f2b177b2000 r--p 00006000 fc:09 109174718                  /lib/x86_64-linux-gnu/librt-2.15.so
7f2b177b2000-7f2b177b3000 rw-p 00007000 fc:09 109174718                  /lib/x86_64-linux-gnu/librt-2.15.so
7f2b177b3000-7f2b177cb000 r-xp 00000000 fc:09 109174843                  /lib/x86_64-linux-gnu/libpthread-2.15.so
7f2b177cb000-7f2b179ca000 ---p 00018000 fc:09 109174843                  /lib/x86_64-linux-gnu/libpthread-2.15.so
7f2b179ca000-7f2b179cb000 r--p 00017000 fc:09 109174843                  /lib/x86_64-linux-gnu/libpthread-2.15.so
7f2b179cb000-7f2b179cc000 rw-p 00018000 fc:09 109174843                  /lib/x86_64-linux-gnu/libpthread-2.15.so
7f2b179cc000-7f2b179d0000 rw-p 00000000 00:00 0 
7f2b179d0000-7f2b17b84000 r-xp 00000000 fc:09 109174840                  /lib/x86_64-linux-gnu/libc-2.15.so
7f2b17b84000-7f2b17d83000 ---p 001b4000 fc:09 109174840                  /lib/x86_64-linux-gnu/libc-2.15.so
7f2b17d83000-7f2b17d87000 r--p 001b3000 fc:09 109174840                  /lib/x86_64-linux-gnu/libc-2.15.so
7f2b17d87000-7f2b17d89000 rw-p 001b7000 fc:09 109174840                  /lib/x86_64-linux-gnu/libc-2.15.so
7f2b17d89000-7f2b17d8e000 rw-p 00000000 00:00 0 
7f2b17d8e000-7f2b18041000 r-xp 00000000 fc:09 68248128                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/libruby.so.2.4.0
7f2b18041000-7f2b18240000 ---p 002b3000 fc:09 68248128                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/libruby.so.2.4.0
7f2b18240000-7f2b18246000 r--p 002b2000 fc:09 68248128                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/libruby.so.2.4.0
7f2b18246000-7f2b18249000 rw-p 002b8000 fc:09 68248128                   /home/travis/.rvm/rubies/ruby-2.4.0/lib/libruby.so.2.4.0
7f2b18249000-7f2b1825b000 rw-p 00000000 00:00 0 
7f2b1825b000-7f2b1827d000 r-xp 00000000 fc:09 109174846                  /lib/x86_64-linux-gnu/ld-2.15.so
7f2b182f2000-7f2b18314000 r--s 00000000 fc:09 109174843                  /lib/x86_64-linux-gnu/libpthread-2.15.so
7f2b18314000-7f2b18335000 r--s 00000000 fc:09 34072                      /home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby
7f2b18335000-7f2b1846c000 rw-p 00000000 00:00 0 
7f2b18476000-7f2b18477000 rw-p 00000000 00:00 0 
7f2b18477000-7f2b18478000 ---p 00000000 00:00 0 
7f2b18478000-7f2b1847d000 rw-p 00000000 00:00 0 
7f2b1847d000-7f2b1847e000 r--p 00022000 fc:09 109174846                  /lib/x86_64-linux-gnu/ld-2.15.so
7f2b1847e000-7f2b18480000 rw-p 00023000 fc:09 109174846                  /lib/x86_64-linux-gnu/ld-2.15.so
7fffbeeed000-7fffbf6ec000 rw-p 00000000 00:00 0                          [stack]
7fffbf7da000-7fffbf7dc000 r--p 00000000 00:00 0                          [vvar]
7fffbf7dc000-7fffbf7de000 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

/home/travis/build.sh: line 62:  3301 Aborted                 (core dumped) ruby -e 'p Thread.new(1, &:to_s).value'

Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Bug #13398: segfault: Thread.new(foo, &:bar)RejectedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED
Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r57969.


thread.c: Thread.start with Symbol

  • thread.c (thread_do_start): fix segfault at start with Symbol.
    proc created by Symbol#to_proc does not have environment unless
    using refinements. [ruby-core:80147] [Bug #13313]

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r58003 merged revision(s) 57968,57969,57970.

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Has duplicate Bug #13398: segfault: Thread.new(foo, &:bar) added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0