Project

General

Profile

Actions

Bug #22533

open

Peephole optimizer infinite loop

Bug #22533: Peephole optimizer infinite loop

Added by tekknolagi (Maxwell Bernstein) 2 days ago. Updated 1 day ago.

Status:
Open
Assignee:
-
Target version:
[ruby-core:127409]

Description

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.


Related issues 1 (0 open — 1 closed)

Related to Ruby - Bug #20572: Compilation hangs with nested untilClosedActions
Actions

Also available in: PDF Atom