From: "jamescook83 (James Cook) via ruby-core" Date: 2026-10-31T09:37:40+00:00 Subject: [ruby-core:127288] [Ruby Bug#22489] RubyVM::InstructionSequence#to_a segfaults or hangs when called on the same iseq from multiple Ractors Issue #22489 has been updated by jamescook83 (James Cook). This is fixed in 4.1.0-preview1 by 99f2ef9c1f (Fix data race in rb_iseq_original_iseq). I couldn't find an existing issue for it in the tracker. I think this can be closed. ---------------------------------------- Bug #22489: RubyVM::InstructionSequence#to_a segfaults or hangs when called on the same iseq from multiple Ractors https://bugs.ruby-lang.org/issues/22489#change-119712 * Author: jamescook83 (James Cook) * Status: Open * ruby -v: ruby 4.0.8 (2026-10-22 revision 60c3d71bfb) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ``` # Several Ractors call InstructionSequence#to_a on the same blocks at once. # Expected: prints "survived". Actual: segfault, bus error or hang. # Usage: ruby repro.rb [how many blocks] [lines in each block] Warning[:experimental] = false BLOCKS = Integer(ARGV.fetch(0, 400)) LINES = Integer(ARGV.fetch(1, 300)) module Blocks; end body = "x = [1].map { |v| v + 1 }\n" * LINES BLOCKS.times { |n| Blocks.module_eval("def self.block_#{n} = proc {\n#{body}}") } ractors = Array.new(7) do Ractor.new do BLOCKS.times { |n| RubyVM::InstructionSequence.of(Blocks.send("block_#{n}")).to_a } end end ractors.each(&:value) puts "survived" ``` ``` ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� blocks �� lines ��� 6 runs each ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� 400 �� 300 (default) ��� 5 segfaults, 1 hang ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� 100 �� 100 ��� 1 segfault, 1 bus error, 3 hangs, 1 survived ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� 20 �� 20 ��� 1 hang, 5 survived ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� 5 �� 5 ��� 6 survived ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��� 1 �� 1 ��� 6 survived ��� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ``` I'm working around it with a exclusive file lock around calls to `RubyVM::InstructionSequence.of(...)` to force the ractors to take turns. ---Files-------------------------------- iseq_ractors_crash.txt (2.52 KB) -- 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/