From: "byroot (Jean Boussier) via ruby-core" Date: 2026-11-11T13:31:22+00:00 Subject: [ruby-core:127417] [Ruby Bug#22533] Peephole optimizer infinite loop Issue #22533 has been updated by byroot (Jean Boussier). I have a patch for this: https://github.com/ruby/ruby/pull/19844, but I'm not 100% certain it doesn't regress this optimization, and based on the handful of failing ZJIT tests, it looks like it does generate different code sometimes. So I'd appreciate if someone with more knowledge of the peephole optimizer could review. ---------------------------------------- Bug #22533: Peephole optimizer infinite loop https://bugs.ruby-lang.org/issues/22533#change-119863 * Author: tekknolagi (Maxwell Bernstein) * Status: Open * Target version: 4.0 * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- The following code compiles a small loop with and without the peephole optimizer. It spawns a subprocess and waits 5 seconds before killing it to demonstrate the hang. SRC = "while true; if true then 1 end; end" pid = fork do RubyVM::InstructionSequence.compile(SRC) exit!(0) end deadline = Time.now + 5 status = nil while Time.now < deadline break if (status = Process.waitpid2(pid, Process::WNOHANG)) sleep 0.05 end if status puts "compiled (#{status[1].inspect}): not reproduced" else Process.kill(:KILL, pid) Process.wait(pid) puts "compile_parsey(#{SRC.inspect}) still running after 5s: killed (hang)" end ok = RubyVM::InstructionSequence.compile(SRC, nil, nil, 1, peephole_optimization: false) puts "without the peephole pass it compiles: #{ok.to_a[13].size} body entries" It also happens with `.compile_parsey`. This affects at least 3.4+ through master. -- 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/