From: marcandre-ruby-core@...
Date: 2021-01-12T01:42:47+00:00
Subject: [ruby-core:102009] [Ruby master Bug#17529] Ractor Segfaults with GC enabled
Issue #17529 has been updated by marcandre (Marc-Andre Lafortune).
Thanks for the report.
Probably the same bug as #17489
----------------------------------------
Bug #17529: Ractor Segfaults with GC enabled
https://bugs.ruby-lang.org/issues/17529#change-89856
* Author: prajjwal (Prajjwal Singh)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I've been benchmarking `Ractor` on my machine with the following naive prime number generator:
```ruby
# frozen_string_literal: true
def prime?(n)
2.upto(n - 1).none? { |i| n % i == 0 }
end
NUM_WORKERS = ARGV[0].to_i
producer = Ractor.new do
i = 1000000
loop { Ractor.yield i; i += 1 }
end
workers = (1..NUM_WORKERS).map do
Ractor.new producer do |producer|
while n = producer.take
Ractor.yield [n, prime?(n)]
end
end
end
loop do
_r, ( number, prime ) = Ractor.select(*workers)
p number if prime
end
```
The code inevitably segfaults, and it appears to be the garbage collector.
If I stick `GC.disable` in there, the code happily chugs along for several minutes on end without a problem.
---Files--------------------------------
ractor.crash (22.5 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>