Repository navigation
JIT (correctness): Different UnboundLocalError for same code with JIT on or off #140104
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Oct 14, 2025 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Oct 14, 2025 It's possible #139109 might end up fixing this inadvertently, so let's not fix this for now maybe? Or we could fix it with the knowledge the code will be ripped out soon.
Here's a simpler reproducer for what seems to be the same issue:
def f(): for i in range(500): try: g(i) except Exception: pass for _ in range(5000): f()
This one runs to completion without the JIT and raises an exception with it.
We need a backport for 3.14, don't we?
Or we ignore backports since JIT is in expiremental stage?Let's backport to 3.14 but not 3.13.
Reacted by Mikhail EfimovBackport failed, maybe I should open up the backport to anyone who wants to try please?
Backport failed, maybe I should open up the backport to anyone who wants to try please?
I'd like to provide this backport.
Reacted by Ken JinReacted by Ken Jin- added a commit that references this issue
on Oct 27, 2025 This is still broken on 3.14 sadly.
This is still broken on 3.14 sadly.
I'm sorry. It seems that I've tested incorrectly.
It's actually still broken on 3.14.This is still broken on 3.14 sadly.
I'm sorry. It seems that I've tested incorrectly. It's actually still broken on 3.14.
No worries. I didn't realize CI didn't trigger for JIT on the backport either!
Reacted by Mikhail Efimov- added a commit that references this issue
on Nov 1, 2025 - added a commit that references this issue
on Nov 13, 2025
Bug report
Bug description:
The following code results in two different
UnboundLocalErrorexceptions depending on whether it's run with the JIT on or off:With JIT on, the
UnboundLocalErrorpoints to'instance', while with JIT off it points to'Class'.Traceback with JIT on:
Traceback with JIT off:
Output for
PYTHON_LLTRACE=4:divergence_01_lltrace.txt
Output for
PYTHON_OPT_DEBUG=4:divergence_01_opt_debug.txt
Please let me know whether you're able to reproduce this issue.
Found using lafleur.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs