Project

General

Profile

Actions

Bug #18816

closed

Ractor segfaulting MacOS 12.4 (aarch64 / M1 processor)

Added by brodock (Gabriel Mazetto) almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
[ruby-core:108771]

Description

Reproduction server:

require 'socket'

# Set based on CPU count
CONCURRENCY = 8

server = TCPServer.new(8080)
workers = CONCURRENCY.times.map do
  Ractor.new do
    loop do
      # receive TCPSocket
      session = Ractor.recv

      request = session.gets
      puts request

      session.print "HTTP/1.1 200\r\n"
      session.print "Content-Type: text/html\r\n"
      session.print "\r\n"
      session.print "Hello world! Current time is #{Time.now}"
      session.close
    end
  end
end

loop do
  conn, _ = server.accept

  # pass TCPSocket to one of the workers
  workers.sample.send(conn, move: true)
end

run apache benchmark against code above:

ab -n 20000 -c 20 http://localhost:8080/

ractorserver-crash.rb:21: [BUG] Segmentation fault at 0xf94012a9aa1503e8
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

-- Crash Report log information --------------------------------------------
   See Crash Report log file in one of the following locations:
     * ~/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:0005 p:---- s:0019 e:000018 CFUNC  :close
c:0004 p:0074 s:0015 e:000014 BLOCK  ractorserver-crash.rb:21 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC  :loop
c:0002 p:0004 s:0006 e:000005 BLOCK  ractorserver-crash.rb:10 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
ractorserver-crash.rb:10:in `block (2 levels) in <main>'
ractorserver-crash.rb:10:in `loop'
ractorserver-crash.rb:21:in `block (3 levels) in <main>'
ractorserver-crash.rb:21:in `close'

-- Machine register context ------------------------------------------------
  x0: 0x0000000000000000  x1: 0x000000011d009a00  x2: 0x0000000000000000
  x3: 0x0000000000000000  x4: 0x000000016be1a034  x5: 0x0000000000000000
  x6: 0x0000000000000030  x7: 0x000000016be1a050 x18: 0x0000000000000000
 x19: 0x000000016be1a098 x20: 0x000000000000000c x21: 0x000000011d009a00
 x22: 0x0000000104f046a8 x23: 0x000000011d009b60 x24: 0xf94012a9aa1503e8
 x25: 0x0000000000000002 x26: 0x00006000029d66a0 x27: 0x0000000000000000
 x28: 0x0000000055550083  lr: 0x0000000104dddad4  fp: 0x000000016be1a080
  sp: 0x000000016be1a030

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

* Loaded script: ractorserver-crash.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 fiber.so
    3 rational.so
    4 complex.so
    5 ruby2_keywords.rb
    6 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
    7 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/trans/transdb.bundle
    8 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/rbconfig.rb
    9 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/compatibility.rb
   10 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/defaults.rb
   11 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/deprecate.rb
   12 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/errors.rb
   13 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/unknown_command_spell_checker.rb
   14 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/exceptions.rb
   15 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/basic_specification.rb
   16 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/stub_specification.rb
   17 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/platform.rb
   18 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/version.rb
   19 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/requirement.rb
   20 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/util/list.rb
   21 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/specification.rb
   22 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/util.rb
   23 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/dependency.rb
   24 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_gem.rb
   25 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/monitor.bundle
   26 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/monitor.rb
   27 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb
   28 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_warn.rb
   29 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems.rb
   30 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/path_support.rb
   31 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/error_highlight/version.rb
   32 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/error_highlight/base.rb
   33 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/error_highlight/formatter.rb
   34 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/error_highlight/core_ext.rb
   35 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/error_highlight.rb
   36 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/version.rb
   37 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/core_ext/name_error.rb
   38 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/levenshtein.rb
   39 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/jaro_winkler.rb
   40 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checker.rb
   41 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   42 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   43 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/name_error_checkers.rb
   44 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/method_name_checker.rb
   45 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/key_error_checker.rb
   46 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/null_checker.rb
   47 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/tree_spell_checker.rb
   48 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/require_path_checker.rb
   49 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/spell_checkers/pattern_key_name_checker.rb
   50 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean/formatter.rb
   51 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/did_you_mean.rb
   52 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
   53 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/io/wait.bundle
   54 /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/socket.rb

* Process memory map:

104590000-104594000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/bin/ruby
104594000-104598000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/bin/ruby
104598000-10459c000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/bin/ruby
10459c000-10469c000 r-- /usr/lib/dyld
10469c000-1046a4000 rw- /usr/lib/dyld
1046a4000-1046a8000 r-- /usr/lib/dyld
1046a8000-1046ac000 r-- /usr/lib/dyld
1046ac000-1046b0000 rw- /usr/lib/dyld
1046b0000-1046b4000 --- /usr/lib/dyld
1046b4000-1046bc000 rw- /usr/lib/dyld
1046bc000-1046c0000 --- /usr/lib/dyld
1046c0000-1046c4000 --- /usr/lib/dyld
1046c4000-1046cc000 rw- /usr/lib/dyld
1046cc000-1046d0000 --- /usr/lib/dyld
1046d0000-1046d4000 --- /usr/lib/dyld
1046d4000-1046dc000 rw- /usr/lib/dyld
1046dc000-1046e0000 --- /usr/lib/dyld
1046e0000-1046e4000 r-- /usr/lib/dyld
1046e4000-1046e8000 r-- /usr/lib/dyld
1046e8000-1046ec000 rw- /usr/lib/dyld
1046ec000-1046f0000 r-- /usr/lib/dyld
1046f4000-1046f8000 rw- /usr/lib/dyld
1046fc000-104700000 rw- /usr/lib/dyld
104704000-104708000 rw- /usr/lib/dyld
10470c000-10476c000 r-x /usr/lib/dyld
10476c000-104784000 r-- /usr/lib/dyld
104784000-104788000 rw- /usr/lib/dyld
104788000-1047c0000 r-- /usr/lib/dyld
1047c0000-104800000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104804000-104808000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10480c000-104810000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104814000-104818000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10481c000-104820000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104824000-104828000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10482c000-104830000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104834000-104838000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10483c000-104840000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104844000-104848000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10484c000-104850000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104854000-104858000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10485c000-104860000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104864000-104868000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10486c000-104870000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104874000-104878000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10487c000-104880000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104884000-104888000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10488c000-104890000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
104894000-104898000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
10489c000-1048a0000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048a4000-1048a8000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048ac000-1048b0000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048b4000-1048b8000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048b8000-1048bc000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048bc000-1048c0000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/encdb.bundle
1048c0000-1048c4000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/trans/transdb.bundle
1048c4000-1048c8000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/trans/transdb.bundle
1048c8000-1048cc000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/enc/trans/transdb.bundle
1048d0000-1048d4000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
1048d8000-1048dc000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
1048e0000-1048e4000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
1048e8000-1048ec000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
1048f0000-1048f4000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
1048f8000-1048fc000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104900000-104a00000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a04000-104a08000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a0c000-104a10000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a14000-104a18000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a1c000-104a20000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a24000-104a28000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a2c000-104a30000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a34000-104a38000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a3c000-104a40000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a44000-104a48000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a4c000-104a50000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a54000-104a58000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a5c000-104a60000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a64000-104a68000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a6c000-104a70000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a74000-104a78000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a7c000-104a80000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a84000-104a88000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a8c000-104a90000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a94000-104a98000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104a9c000-104aa0000 rw- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104aa0000-104aac000 r-- /Library/Preferences/Logging/.plist-cache.XCihH5sw
104aac000-104ab0000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/monitor.bundle
104ab0000-104ab4000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/monitor.bundle
104ab4000-104ab8000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/monitor.bundle
104ab8000-104abc000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/monitor.bundle
104abc000-104ac0000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/io/wait.bundle
104ac0000-104ac4000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/io/wait.bundle
104ac4000-104ac8000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/io/wait.bundle
104ac8000-104acc000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/io/wait.bundle
104ad0000-104ad4000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104ad8000-104adc000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104ae0000-104ae4000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104ae8000-104aec000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104af0000-104af4000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104af8000-104b1c000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104b1c000-104b20000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104b20000-104b24000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104b24000-104b34000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/arm64-darwin21/socket.bundle
104b38000-104b3c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b40000-104b44000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b48000-104b4c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b50000-104b54000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b58000-104b5c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b60000-104b64000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b68000-104b6c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b70000-104b74000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b78000-104b7c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b80000-104b84000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b88000-104b8c000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104b90000-104b94000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104bdc000-104efc000 r-x /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104efc000-104f04000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104f04000-104f08000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104f08000-104f14000 rw- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
104f14000-105004000 r-- /Users/brodock/.rvm/rubies/ruby-3.1.2/lib/libruby.3.1.dylib
105008000-107008000 rw-
107008000-10700c000 ---
10700c000-1070b0000 rw-
1070b0000-1070b4000 ---
1070b4000-107158000 rw-
107158000-10715c000 ---
10715c000-107200000 rw-
107200000-107204000 ---
107204000-1072a8000 rw-
1072a8000-1072ac000 ---
1072ac000-107350000 rw-
107350000-107354000 ---
107354000-1073f8000 rw-
1073f8000-1073fc000 ---
1073fc000-1074a0000 rw-
1074a0000-1074a4000 ---
1074a4000-107548000 rw-
107548000-10754c000 ---
10754c000-1075f0000 rw-
1075f0000-1075f4000 ---
1075f4000-107698000 rw-
107698000-10769c000 ---
10769c000-107740000 rw-
107740000-107744000 ---
107744000-1077e8000 rw-
1077e8000-1077ec000 ---
1077ec000-107890000 rw-
107890000-107894000 ---
107894000-107938000 rw-
107938000-10793c000 ---
10793c000-1079e0000 rw-
1079e0000-1079e4000 ---
1079e4000-107a88000 rw-
107a88000-107a8c000 ---
107a8c000-107b30000 rw-
107b30000-107b34000 ---
107b34000-107bd8000 rw-
107bd8000-107bdc000 ---
107bdc000-107c80000 rw-
107c80000-107c84000 ---
107c84000-107d28000 rw-
107d28000-107d2c000 ---
107d2c000-107dd0000 rw-
107dd0000-107dd4000 ---
107dd4000-107e78000 rw-
107e78000-107e7c000 ---
107e7c000-107f20000 rw-
107f20000-107f24000 ---
107f24000-107fc8000 rw-
107fc8000-107fcc000 ---
107fcc000-108070000 rw-
108070000-108074000 ---
108074000-108118000 rw-
108118000-10811c000 ---
10811c000-1081c0000 rw-
1081c0000-1081c4000 ---
1081c4000-108268000 rw-
108268000-10826c000 ---
10826c000-108310000 rw-
108310000-108314000 ---
108314000-1083b8000 rw-
1083b8000-1083bc000 ---
1083bc000-108460000 rw-
108460000-108464000 ---
108464000-108508000 rw-
108600000-108700000 rw-
108800000-109000000 rw-
109000000-109800000 rw-
109800000-10a000000 rw-
10a000000-10a800000 rw-
10a800000-10b000000 rw-
10d000000-10d800000 rw-
110000000-110800000 rw-
110800000-111000000 rw-
111000000-111800000 rw-
111800000-112000000 rw-
112000000-112800000 rw-
112800000-113000000 rw-
113000000-113800000 rw-
113800000-114000000 rw-
114000000-114800000 rw-
114800000-115000000 rw-
115000000-115800000 rw-
115800000-116000000 rw-
116000000-116800000 rw-
116800000-117000000 rw-
117000000-117800000 rw-
117800000-118000000 rw-
11ce00000-11cf00000 rw-
11cf00000-11d000000 rw-
11d000000-11d800000 rw-
11d800000-11e000000 rw-
120000000-120800000 rw-
120800000-121000000 rw-
121000000-121800000 rw-
121800000-122000000 rw-
122000000-122800000 rw-
122800000-123000000 rw-
123000000-123800000 rw-
123800000-124000000 rw-
124000000-124800000 rw-
124800000-125000000 rw-
125000000-125800000 rw-
125800000-126000000 rw-
126000000-126800000 rw-
126800000-127000000 rw-
127000000-127800000 rw-
127800000-128000000 rw-
128000000-128800000 rw-
128800000-129000000 rw-
129000000-129800000 rw-
129800000-12a000000 rw-
12a000000-12a800000 rw-
12a800000-12b000000 rw-
12b000000-12b800000 rw-
12b800000-12c000000 rw-
12c000000-12c800000 rw-
12c800000-12d000000 rw-
12d000000-12d800000 rw-
12d800000-12e000000 rw-
12e000000-12e800000 rw-
12e800000-12f000000 rw-
12f000000-12f800000 rw-
12f800000-130000000 rw-
167870000-16b074000 ---
16b074000-16b870000 rw-
16b870000-16b874000 ---
16b874000-16b8fc000 rw-
16b8fc000-16b900000 ---
16b900000-16bb08000 rw-
16bb08000-16bb0c000 ---
16bb0c000-16bd14000 rw-
16bd14000-16bd18000 ---
16bd18000-16bf20000 rw-
16bf20000-16bf24000 ---
16bf24000-16c12c000 rw-
16c12c000-16c130000 ---
16c130000-16c338000 rw-
16c338000-16c33c000 ---
16c33c000-16c544000 rw-
16c544000-16c548000 ---
16c548000-16c750000 rw-
16c750000-16c754000 ---
16c754000-16c95c000 rw-
180000000-1e8000000 r--
1e8000000-1e92ac000 r--
1e92ac000-1e92d0000 rw-
1e92d0000-1ea000000 rw-
1ea000000-1ebab8000 r--
1ebab8000-1ed1a8000 rw-
1ed1a8000-1f0528000 r--
1f0528000-1f2000000 r--
1f2000000-220000000 r--
220000000-221b94000 r--
221b94000-222974000 rw-
222974000-223c30000 r--
223c30000-224000000 r--
224000000-280000000 r--
fc0000000-1000000000 ---
1000000000-7000000000 ---
600000000000-600008000000 rw-
600008000000-600010000000 rw-
600010000000-600018000000 rw-
600018000000-600020000000 rw-
[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.

Files

ruby-2022-06-05-021419.ips (50.9 KB) ruby-2022-06-05-021419.ips DiagnosticReports brodock (Gabriel Mazetto), 06/05/2022 01:16 AM
segfault.txt (23.7 KB) segfault.txt tombruijn (Tom de Bruijn), 06/07/2022 02:15 PM
0001-Use-VM-Lock-when-mutating-waiting-threads-list.patch (1.11 KB) 0001-Use-VM-Lock-when-mutating-waiting-threads-list.patch tenderlovemaking (Aaron Patterson), 07/11/2022 07:54 PM
Actions #1

Updated by brodock (Gabriel Mazetto) almost 2 years ago

  • ruby -v set to ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

Updated by tombruijn (Tom de Bruijn) almost 2 years ago

I get the same segfault, but not as consistent as Gabriel. I had to first do a normal request in the browser before running "ab" the couple times it printed the segfault, but I haven't been able to reproduce as consistently. The localhost:8080 server is also unresponsive after running "ab" and I need to kill the process to try again when it doesn't segfault.

Environment details:

  • Ruby 3.1.2p20 installed using ruby-install and managed with chruby. (ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21])
  • macOS 12.4
  • MacBook Pro M1 Pro (14-inch 2021)

Running as:

chruby 3.1.2
ruby app.rb

See attached segfault file of a time that it segfaulted.

Updated by brodock (Gabriel Mazetto) almost 2 years ago

I've tried to isolate the problem with a few attempts:

First guess was that something GC related (cleaning up something that was still in use etc).

I've tried to disable GC with code below:

require 'socket'

# Set based on CPU count
CONCURRENCY = 8

GC.disable

server = TCPServer.new(8080)
workers = CONCURRENCY.times.map do
  Ractor.new do
    loop do
      # receive TCPSocket
      session = Ractor.recv

      request = session.gets
      puts request

      session.print "HTTP/1.1 200\r\n"
      session.print "Content-Type: text/html\r\n"
      session.print "\r\n"
      session.print "Hello world! Current time is #{Time.now}"
      session.close
    end
  end
end

loop do
  conn, _ = server.accept

  # pass TCPSocket to one of the workers
  workers.sample.send(conn, move: true)
end

still get segfault.

Then tried to run the same code with 3.1.2 compiled with jemalloc, assuming could be something malloc related, still get a segfault.

Updated by brodock (Gabriel Mazetto) almost 2 years ago

I've tried to reproduce the problem in a container running from the M1 mac as host, but it seems the issue is mac-specific, as I couldn't make it SEGV.

Linux ac9a228ca7ac 5.15.40-0-virt #1-Alpine SMP Wed, 18 May 2022 08:12:19 +0000 aarch64 GNU/Linux

using ruby:3.1.2 docker tag (running from containerd using rancher-desktop)

Updated by tenderlovemaking (Aaron Patterson) over 1 year ago

I took a look at this, and it looks like we're missing a lock when deleting the fd from waiting_fds list. I've attached a patch that fixes the crash for me. It seems like not every request gets serviced, but I think that might be a different problem.

I've also sent a pull request on GitHub here: https://github.com/ruby/ruby/pull/6116

Actions #6

Updated by tenderlovemaking (Aaron Patterson) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|de51bbcb544651fb499dd4cc757a2bf6f3b439cf.


Use VM Lock when mutating waiting threads list

rb_thread_wait_for_single_fd needs to mutate the waiting_fds list
that is stored on the VM. We need to delete the FD from the list before
returning, and deleting from the list requires a VM lock (because the
list is a global).

[Bug #18816] [ruby-core:108771]

Co-Authored-By: Alan Wu

Updated by brodock (Gabriel Mazetto) over 1 year ago

Can we backport this to 3.0 and 3.1?

Actions #8

Updated by tenderlovemaking (Aaron Patterson) over 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED

Updated by brodock (Gabriel Mazetto) over 1 year ago

I don't get a ruby segfault anymore. It works fine when using no concurrency:

hey -n 20000 http://localhost:8080/                                                                                                               

Summary:
  Total:	22.5328 secs
  Slowest:	1.8602 secs
  Fastest:	0.0004 secs
  Average:	0.0477 secs
  Requests/sec:	887.5935


Response time histogram:
  0.000 [1]	|
  0.186 [17315]	|■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.372 [2634]	|■■■■■■
  0.558 [0]	|
  0.744 [0]	|
  0.930 [0]	|
  1.116 [0]	|
  1.302 [0]	|
  1.488 [0]	|
  1.674 [0]	|
  1.860 [50]	|


Latency distribution:
  10% in 0.0021 secs
  25% in 0.0025 secs
  50% in 0.0029 secs
  75% in 0.0036 secs
  90% in 0.3043 secs
  95% in 0.3081 secs
  99% in 0.3132 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0462 secs, 0.0004 secs, 1.8602 secs
  DNS-lookup:	0.0006 secs, 0.0000 secs, 0.0159 secs
  req write:	0.0001 secs, 0.0000 secs, 0.0052 secs
  resp wait:	0.0012 secs, 0.0000 secs, 0.0118 secs
  resp read:	0.0002 secs, 0.0000 secs, 0.0065 secs

Status code distribution:
  [200]	20000 responses

with -c 20, I get an IOError after a while, which seems to correlate to what you identified as not all requests finishing.

I will open a separate issue for that:

https://bugs.ruby-lang.org/issues/18940

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 99d254d8b025fd952375ed15c345ecc1b806652a merged revision(s) de51bbcb544651fb499dd4cc757a2bf6f3b439cf.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0