[New-bugs-announce] [issue45773] Compiler hangs during jump elimination
Brandt Bucher
report at bugs.python.org
Tue Nov 9 14:56:22 EST 2021
New submission from Brandt Bucher <brandtbucher at gmail.com>:
The following code hangs during compilation on 3.11 and 3.10:
>>> while True or spam: pass
Our peepholer gets stuck in a loop, repeatedly "optimizing" instruction 4 (POP_JUMP_IF_TRUE -> JUMP_ABSOLUTE):
1 0 JUMP_ABSOLUTE 0 (to 0)
2 LOAD_NAME 0 (spam)
4 POP_JUMP_IF_TRUE 0 (to 0)
After optimizing jumps to jumps like these, we always back up and attempt to optimize the same instruction again (which makes it possible to optimize three or more chained jumps on the same line). The issue is that this particular optimization doesn't actually change the instruction, since both jumps target the same exact block. Since nothing changes, we loop forever.
The fix is really simple: just skip the optimization if instr->i_target == target->i_target. We already do this for several other types of jumps; it just looks like POP_JUMP_IF_TRUE and POP_JUMP_IF_FALSE might have been missed.
I'll have a PR up soon.
----------
assignee: brandtbucher
components: Interpreter Core
messages: 406046
nosy: Mark.Shannon, brandtbucher
priority: high
severity: normal
status: open
title: Compiler hangs during jump elimination
type: crash
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45773>
_______________________________________
More information about the New-bugs-announce
mailing list