]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-104584: Fix error handling from backedge optimization (#106484)
authorGuido van Rossum <guido@python.org>
Thu, 6 Jul 2023 18:39:53 +0000 (11:39 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Jul 2023 18:39:53 +0000 (18:39 +0000)
commit003ba71dcbe94f0d5cb1d0c56d7f1d5a6dae56f7
tree961b7b5af69c94cc5b2d890a6686926e46b2118e
parent56353b10023ff12c7c8d6288ae4bf7bdcd5d4b6c
gh-104584: Fix error handling from backedge optimization (#106484)

When `_PyOptimizer_BackEdge` returns `NULL`, we should restore `next_instr` (and `stack_pointer`). To accomplish this we should jump to `resume_with_error` instead of just `error`.

The problem this causes is subtle -- the only repro I have is in PR gh-106393, at commit d7df54b139bcc47f5ea094bfaa9824f79bc45adc. But the fix is real (as shown later in that PR).

While we're at it, also improve the debug output: the offsets at which traces are identified are now measured in bytes, and always show the start offset. This makes it easier to correlate executor calls with optimizer calls, and either with `dis` output.

<!-- gh-issue-number: gh-104584 -->
* Issue: gh-104584
<!-- /gh-issue-number -->
Python/bytecodes.c
Python/ceval.c
Python/generated_cases.c.h
Python/optimizer.c