* [ruby-core:120671] [Ruby master Bug#21037] Ractors hang with multiple threads
@ 2025-01-14 21:08 tenderlovemaking (Aaron Patterson) via ruby-core
2025-01-15 19:30 ` [ruby-core:120702] " luke-gru (Luke Gruber) via ruby-core
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tenderlovemaking (Aaron Patterson) via ruby-core @ 2025-01-14 21:08 UTC (permalink / raw)
To: ruby-core; +Cc: tenderlovemaking (Aaron Patterson)
Issue #21037 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Bug #21037: Ractors hang with multiple threads
https://bugs.ruby-lang.org/issues/21037
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-14T20:59:39Z master f1e32914eb) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
The following program hangs, but I don't expect it to hang:
```ruby
# frozen_string_literal: true
class Map
def initialize
@r = Ractor.new {
cache = { "int" => "integer", "bool" => "boolean" }
loop do
key = receive
Ractor.yield key
end
}
freeze
end
def fetch(key)
@r.send key
m = @r.take
raise unless key == m
m
end
end
tm = Map.new
t1 = Thread.new { 10.times { |i| p [i + 1,tm.fetch("int")] } }
t2 = Thread.new { 10.times { |i| p [i + 1, tm.fetch("bool")] } }
t1.join
t2.join
```
I'm not sure why this program hangs yet, but it does both on macOS and Linux. I've tested with master, Ruby 3.4, and Ruby 3.3. I'm not sure why it's hanging yet, but I wanted to file an issue.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:120702] [Ruby master Bug#21037] Ractors hang with multiple threads
2025-01-14 21:08 [ruby-core:120671] [Ruby master Bug#21037] Ractors hang with multiple threads tenderlovemaking (Aaron Patterson) via ruby-core
@ 2025-01-15 19:30 ` luke-gru (Luke Gruber) via ruby-core
2025-01-15 20:08 ` [ruby-core:120705] " luke-gru (Luke Gruber) via ruby-core
2025-01-24 21:52 ` [ruby-core:120788] " luke-gru (Luke Gruber) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: luke-gru (Luke Gruber) via ruby-core @ 2025-01-15 19:30 UTC (permalink / raw)
To: ruby-core; +Cc: luke-gru (Luke Gruber)
Issue #21037 has been updated by luke-gru (Luke Gruber).
Maybe this fixes it? https://github.com/ruby/ruby/pull/12520
----------------------------------------
Bug #21037: Ractors hang with multiple threads
https://bugs.ruby-lang.org/issues/21037#change-111537
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-14T20:59:39Z master f1e32914eb) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
The following program hangs, but I don't expect it to hang:
```ruby
# frozen_string_literal: true
class Map
def initialize
@r = Ractor.new {
cache = { "int" => "integer", "bool" => "boolean" }
loop do
key = receive
Ractor.yield key
end
}
freeze
end
def fetch(key)
@r.send key
m = @r.take
raise unless key == m
m
end
end
tm = Map.new
t1 = Thread.new { 10.times { |i| p [i + 1,tm.fetch("int")] } }
t2 = Thread.new { 10.times { |i| p [i + 1, tm.fetch("bool")] } }
t1.join
t2.join
```
I'm not sure why this program hangs yet, but it does both on macOS and Linux. I've tested with master, Ruby 3.4, and Ruby 3.3. I'm not sure why it's hanging yet, but I wanted to file an issue.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:120705] [Ruby master Bug#21037] Ractors hang with multiple threads
2025-01-14 21:08 [ruby-core:120671] [Ruby master Bug#21037] Ractors hang with multiple threads tenderlovemaking (Aaron Patterson) via ruby-core
2025-01-15 19:30 ` [ruby-core:120702] " luke-gru (Luke Gruber) via ruby-core
@ 2025-01-15 20:08 ` luke-gru (Luke Gruber) via ruby-core
2025-01-24 21:52 ` [ruby-core:120788] " luke-gru (Luke Gruber) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: luke-gru (Luke Gruber) via ruby-core @ 2025-01-15 20:08 UTC (permalink / raw)
To: ruby-core; +Cc: luke-gru (Luke Gruber)
Issue #21037 has been updated by luke-gru (Luke Gruber).
It seems calling `ractor.take` from multiple threads is unsupported at the moment. I don't know if this is a limitation or a bug. Of course, you can work around it and call `select` or `take` from a single thread, like main, and signal a ready event with a queue or something for the consumer threads.
----------------------------------------
Bug #21037: Ractors hang with multiple threads
https://bugs.ruby-lang.org/issues/21037#change-111539
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-14T20:59:39Z master f1e32914eb) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
The following program hangs, but I don't expect it to hang:
```ruby
# frozen_string_literal: true
class Map
def initialize
@r = Ractor.new {
cache = { "int" => "integer", "bool" => "boolean" }
loop do
key = receive
Ractor.yield key
end
}
freeze
end
def fetch(key)
@r.send key
m = @r.take
raise unless key == m
m
end
end
tm = Map.new
t1 = Thread.new { 10.times { |i| p [i + 1,tm.fetch("int")] } }
t2 = Thread.new { 10.times { |i| p [i + 1, tm.fetch("bool")] } }
t1.join
t2.join
```
I'm not sure why this program hangs yet, but it does both on macOS and Linux. I've tested with master, Ruby 3.4, and Ruby 3.3. I'm not sure why it's hanging yet, but I wanted to file an issue.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:120788] [Ruby master Bug#21037] Ractors hang with multiple threads
2025-01-14 21:08 [ruby-core:120671] [Ruby master Bug#21037] Ractors hang with multiple threads tenderlovemaking (Aaron Patterson) via ruby-core
2025-01-15 19:30 ` [ruby-core:120702] " luke-gru (Luke Gruber) via ruby-core
2025-01-15 20:08 ` [ruby-core:120705] " luke-gru (Luke Gruber) via ruby-core
@ 2025-01-24 21:52 ` luke-gru (Luke Gruber) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: luke-gru (Luke Gruber) via ruby-core @ 2025-01-24 21:52 UTC (permalink / raw)
To: ruby-core; +Cc: luke-gru (Luke Gruber)
Issue #21037 has been updated by luke-gru (Luke Gruber).
I created a PR here: https://github.com/ruby/ruby/pull/12633. I don't know how to get it working for Win32 builds yet, I'll have to take a closer look at that.
----------------------------------------
Bug #21037: Ractors hang with multiple threads
https://bugs.ruby-lang.org/issues/21037#change-111656
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-14T20:59:39Z master f1e32914eb) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
The following program hangs, but I don't expect it to hang:
```ruby
# frozen_string_literal: true
class Map
def initialize
@r = Ractor.new {
cache = { "int" => "integer", "bool" => "boolean" }
loop do
key = receive
Ractor.yield key
end
}
freeze
end
def fetch(key)
@r.send key
m = @r.take
raise unless key == m
m
end
end
tm = Map.new
t1 = Thread.new { 10.times { |i| p [i + 1,tm.fetch("int")] } }
t2 = Thread.new { 10.times { |i| p [i + 1, tm.fetch("bool")] } }
t1.join
t2.join
```
I'm not sure why this program hangs yet, but it does both on macOS and Linux. I've tested with master, Ruby 3.4, and Ruby 3.3. I'm not sure why it's hanging yet, but I wanted to file an issue.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-24 21:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 21:08 [ruby-core:120671] [Ruby master Bug#21037] Ractors hang with multiple threads tenderlovemaking (Aaron Patterson) via ruby-core
2025-01-15 19:30 ` [ruby-core:120702] " luke-gru (Luke Gruber) via ruby-core
2025-01-15 20:08 ` [ruby-core:120705] " luke-gru (Luke Gruber) via ruby-core
2025-01-24 21:52 ` [ruby-core:120788] " luke-gru (Luke Gruber) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).