Project

General

Profile

Actions

Bug #18024

closed

Ractor crashes when connections are closed in multiple Ractors

Added by tagomoris (Satoshi Tagomori) over 3 years ago. Updated about 1 year ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
[ruby-dev:51080]

Description

When multiple Ractors will accept and close connections, that script caused the crash shown below.
This pattern is taken when we want to distribute the overhead of accept to multiple CPU cores.

Script:

require 'socket'

try_times = 10
worker_num = 2

listener = TCPServer.new("127.0.0.1", 8228)
listener.listen(100)
workers = worker_num.times.map do |i|
  Ractor.new(i, listener.dup) do |index, sock|
    while conn = sock.accept
      begin
        data = conn.read
        p "Worker|#{index} Data: #{data}"
        conn.close
      rescue => e
        p "Worker|#{index} #{e.full_message}"
      end
    end
  rescue => e
    $stderr.puts "Error, worker#{index}: #{e.full_message}"
  end
end

p "Starting a sender"
sender = Ractor.new(try_times) do |tries|
  tries.times.each do
    s = TCPSocket.new("127.0.0.1", 8228)
    s.write("yay")
  ensure
    s.close rescue nil
  end
end

sender.take
workers.each{|w| w.take}
p "End"

Crash report:

<internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
"Starting a sender"
"Worker|1 Data: yay"
snippets/ractor_accept.rb:30: [BUG] Bus Error at 0x00000014000001f5
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]

-- 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:0006 p:---- s:0023 e:000022 CFUNC  :close
c:0005 p:0028 s:0019 e:000017 BLOCK  snippets/ractor_accept.rb:30 [FINISH]
c:0004 p:---- s:0014 e:000013 CFUNC  :times
c:0003 p:---- s:0011 e:000010 CFUNC  :each
c:0002 p:0008 s:0007 e:000006 BLOCK  snippets/ractor_accept.rb:26 [FINISH]
c:0001 p:---- s:0003 e:000002 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
snippets/ractor_accept.rb:26:in `block in <main>'
snippets/ractor_accept.rb:26:in `each'
snippets/ractor_accept.rb:26:in `times'
snippets/ractor_accept.rb:30:in `block (2 levels) in <main>'
snippets/ractor_accept.rb:30:in `close'

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

* Loaded script: snippets/ractor_accept.rb

* Loaded features:

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

* Process memory map:

1042f8000-1042fc000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/bin/ruby
1042fc000-104300000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/bin/ruby
104300000-104304000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/bin/ruby
104304000-104308000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/bin/ruby
104308000-104310000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104310000-104314000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104314000-104318000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104318000-10431c000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
10431c000-104320000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104320000-104328000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104328000-10432c000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
10432c000-104330000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104330000-104338000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104338000-10433c000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
10433c000-104340000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104340000-104348000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104348000-10434c000 --- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
10434c000-104350000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104350000-104354000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104354000-104394000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104394000-104398000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
104398000-10439c000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
10439c000-1043a0000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
1043a0000-1043a4000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/encdb.bundle
1043a4000-1043a8000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/trans/transdb.bundle
1043a8000-1043ac000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/trans/transdb.bundle
1043ac000-1043b0000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/trans/transdb.bundle
1043b0000-1043b4000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/enc/trans/transdb.bundle
1043b4000-1043b8000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/monitor.bundle
1043b8000-1043bc000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/monitor.bundle
1043bc000-1043c0000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/monitor.bundle
1043c0000-1043c4000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/monitor.bundle
1043c4000-1043e8000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/socket.bundle
1043e8000-1043ec000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/socket.bundle
1043ec000-1043f0000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/socket.bundle
1043f0000-104400000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/socket.bundle
104400000-104404000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/io/wait.bundle
104404000-104408000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/io/wait.bundle
104408000-10440c000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/io/wait.bundle
10440c000-104410000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/ruby/3.0.0/arm64-darwin20/io/wait.bundle
104568000-1045e8000 r-x /usr/lib/dyld
1045e8000-1045f0000 r-- /usr/lib/dyld
1045f0000-1045f4000 rw- /usr/lib/dyld
1045f4000-104628000 rw- /usr/lib/dyld
104628000-10466c000 r-- /usr/lib/dyld
10466c000-104670000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
104670000-104974000 r-x /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
104974000-10497c000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
10497c000-104980000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
104980000-10498c000 rw- /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
10498c000-104a7c000 r-- /Users/tagomoris/.rbenv/versions/3.0.0/lib/libruby.3.0.dylib
104a7c000-104a80000 ---
104a80000-104b24000 rw-
104b24000-104b28000 ---
104b28000-104bcc000 rw-
104bcc000-104bd0000 ---
104bd0000-104c74000 rw-
104c74000-104c78000 ---
104c78000-104d1c000 rw-
104d1c000-104d20000 ---
104d20000-104dc4000 rw-
104dc4000-104dc8000 ---
104dc8000-104e6c000 rw-
104e6c000-104e70000 ---
104e70000-104f14000 rw-
104f14000-104f18000 ---
104f18000-104fbc000 rw-
104fbc000-104fc0000 ---
104fc0000-105064000 rw-
105064000-105068000 ---
105068000-10510c000 rw-
10510c000-105110000 ---
105110000-1051b4000 rw-
1051b4000-1051b8000 ---
1051b8000-10525c000 rw-
10525c000-105260000 ---
105260000-105304000 rw-
105304000-105308000 ---
105308000-1053ac000 rw-
1053ac000-1053b0000 ---
1053b0000-105454000 rw-
105454000-105458000 ---
105458000-1054fc000 rw-
1054fc000-105500000 ---
105500000-1055a4000 rw-
1055a4000-1055a8000 ---
1055a8000-10564c000 rw-
10564c000-105650000 ---
105650000-1056f4000 rw-
1056f4000-1056f8000 ---
1056f8000-10579c000 rw-
10579c000-1057a0000 ---
1057a0000-105844000 rw-
105844000-105848000 ---
105848000-1058ec000 rw-
1058ec000-1058f0000 ---
1058f0000-105994000 rw-
105994000-105998000 ---
105998000-105a3c000 rw-
105a3c000-105a40000 ---
105a40000-105ae4000 rw-
105ae4000-105ae8000 ---
105ae8000-105b8c000 rw-
105b8c000-105b90000 ---
105b90000-105c34000 rw-
105c34000-105c38000 ---
105c38000-105cdc000 rw-
105cdc000-105ce0000 ---
105ce0000-105d84000 rw-
105d84000-105d88000 ---
105d88000-105e2c000 rw-
105e2c000-105e30000 ---
105e30000-105ed4000 rw-
105ed4000-105ed8000 ---
105ed8000-105f7c000 rw-
131e00000-131f00000 rw-
132000000-132800000 rw-
132800000-133000000 rw-
138000000-138800000 rw-
138800000-139000000 rw-
139000000-139800000 rw-
139800000-13a000000 rw-
13a000000-13a800000 rw-
13a800000-13b000000 rw-
13b000000-13b800000 rw-
13b800000-13c000000 rw-
13c000000-13c800000 rw-
13c800000-13d000000 rw-
13d000000-13d800000 rw-
13d800000-13e000000 rw-
13e000000-13e800000 rw-
13e800000-13f000000 rw-
13f000000-13f800000 rw-
13f800000-140000000 rw-
141e00000-141f00000 rw-
141f00000-142000000 rw-
142000000-142800000 rw-
148000000-148800000 rw-
148800000-149000000 rw-
149000000-149800000 rw-
149800000-14a000000 rw-
14a000000-14a800000 rw-
14a800000-14b000000 rw-
14b000000-14b800000 rw-
14b800000-14c000000 rw-
14c000000-14c800000 rw-
14c800000-14d000000 rw-
14d000000-14d800000 rw-
14d800000-14e000000 rw-
14e000000-14e800000 rw-
14e800000-14f000000 rw-
14f000000-14f800000 rw-
14f800000-150000000 rw-
151e00000-151f00000 rw-
151f00000-152000000 rw-
152000000-152800000 rw-
152800000-153000000 rw-
153000000-155000000 rw-
155000000-155004000 rw-
155100000-155200000 rw-
158000000-158800000 rw-
158800000-159000000 rw-
159000000-159800000 rw-
159800000-15a000000 rw-
15a000000-15a800000 rw-
15a800000-15b000000 rw-
15b000000-15b800000 rw-
15b800000-15c000000 rw-
15c000000-15c800000 rw-
15c800000-15d000000 rw-
15d000000-15d800000 rw-
15d800000-15e000000 rw-
15e000000-15e800000 rw-
15e800000-15f000000 rw-
15f000000-15f800000 rw-
15f800000-160000000 rw-
167b08000-16b30c000 ---
16b30c000-16bb08000 rw-
16bb08000-16bb0c000 ---
16bb0c000-16bb94000 rw-
16bb94000-16bb98000 ---
16bb98000-16bda0000 rw-
16bda0000-16bda4000 ---
16bda4000-16bfac000 rw-
16bfac000-16bfb0000 ---
16bfb0000-16c1b8000 rw-
180000000-190000000 r--
190000000-1a0000000 r--
1a0000000-1b0000000 r--
1b0000000-1c0000000 r--
1c0000000-1d0000000 r--
1d0000000-1e0000000 r--
1e0000000-1e6000000 r--
1e6000000-1e6e2c000 r--
1e6e2c000-1e8000000 rw-
1e8000000-1f0000000 r--
1f0000000-1f2000000 r--
1f2000000-1f2bcc000 r--
1f2bcc000-1f4864000 rw-
1f4864000-1f6000000 r--
1f6000000-1f6864000 r--
1f6864000-1fa57c000 r--
1fa57c000-1fc000000 r--
1fc000000-200000000 r--
200000000-210000000 r--
210000000-220000000 r--
220000000-230000000 r--
230000000-240000000 r--
240000000-250000000 r--
250000000-260000000 r--
260000000-270000000 r--
270000000-280000000 r--
fc0000000-1000000000 ---
1000000000-7000000000 ---
[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.

Abort trap: 6

Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0