
Issue #19611 has been updated by kjtsanaktsidis (KJ Tsanaktsidis). Hm, interesting - it falls into an infinite loop in `iseq_peephole_optimize`, because it's doing useless jump elimination on labels that recursively point to each other. At the beginning of `iseq_peephole_optimize`, the instruction sequence of your `hoge` method looks like this: ``` -- raw disasm-------- 0000 jump <L000> ( 2) <L004> [sp: -1] 0002 putnil ( 2) <L005> [sp: -1] 0003 pop ( 2) 0004 jump <L000> ( 2) <L001> [sp: -1] <L000> [sp: -1] 0006 jump <L006> ( 2) <L006> [sp: -1] 0008 jump <L001> ( 2) <L003> [sp: -1] adjust: [label: 4] 0010 putnil ( 2) <L002> [sp: -1] trace: 10 0011 leave ( 4) --------------------- ``` Looks like the peephole optimizer is continuously changing that first jump to point to L006, then L001, then L006 again, forever. This PR should fix it I think: https://github.com/ruby/ruby/pull/7760 ---------------------------------------- Bug #19611: Ruby hangs up with `while true && true` https://bugs.ruby-lang.org/issues/19611#change-102905 * Author: tompng (tomoya ishida) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) +YJIT [x86_64-darwin20] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Fails to run this code. It hangs up. Ctrl+C does not work. ~~~ruby def hoge while true && true end end ~~~ Compiling `while true && true; end` will also hangs up ~~~ruby irb(main):001:0> RubyVM::InstructionSequence.compile 'while true && true; end'; puts :done (no response) ~~~ -- https://bugs.ruby-lang.org/