Project

General

Profile

Actions

Bug #17529

closed

Ractor Segfaults with GC enabled

Added by prajjwal (Prajjwal Singh) over 3 years ago. Updated about 2 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
[ruby-core:102008]

Description

I've been benchmarking Ractor on my machine with the following naive prime number generator:

# 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) ractor.crash prajjwal (Prajjwal Singh), 01/12/2021 01:12 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #17489: Ractor segfaultsClosedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0