Project

General

Profile

Bug #20779 ยป hang.rb

simple script to reproduce the issue. - hms (Hal Spitz), 10/02/2024 11:22 PM

 
#!/usr/bin/env ruby

# frozen_string_literal: true
RubyVM::YJIT.enable
puts "YJIT enabled? #{RubyVM::YJIT.enabled?}"

num_threads = 12_000 # working on my system
# num_threads = 13_000 # freezes the process on my system
threads = []

num_threads.times do |iter|
if iter % 1_000 == 0
alive = threads.count(&:alive?)
puts "Thread creation iteration #{iter} -- Alive count #{alive}"
end

threads << Thread.new do
Thread.stop
rescue => e
puts "Unable to create thread #{e}"
end
end

puts 'Waiting on Threads'
STDIN.getc
threads.each(&:run)

loop do
alive = threads.count(&:alive?)
break if alive.zero?
puts "Alive count #{alive}"

sleep 3
end

threads.each(&:join)
puts "Clean exit"
    (1-1/1)