This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Assert oparg < INSTR_OFFSET()
Type: compile error Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon, kj, pablogsal, steve.dower, vstinner
Priority: release blocker Keywords:

Created on 2021-10-08 19:33 by steve.dower, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (12)
msg403495 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-08 19:33
encodings.search_function is triggering this assertion at Python/ceval.c#L4055:

       TARGET(JUMP_ABSOLUTE) {
            PREDICTED(JUMP_ABSOLUTE);
            assert(oparg < INSTR_OFFSET());    <<<

It seems to be saying that absolute jumps should only go backwards?

The assertion is triggering reliably in a Windows debug build (including as part of the build process, which means we can't release right now). I don't see anything Windows-specific here though, so I assume it's core and may just be a codepath in encodings that Linux doesn't use?
msg403496 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-08 19:35
+Pablo because of blocker.

+Mark because it seems like f6eafe18c004 is probably the cause
msg403498 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-08 19:50
Also +Victor, because I think we should switch back to debug builds in CI in order to catch failed assertions before they get merged.

Since you're the most strongly against this, I wanted to give you a chance to argue against it (or suggest a better approach than just switching to the debug build).
msg403499 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-08 20:05
I bet you can trigger this on Linux compiling with '--without-computed-gotos'.

Maybe we need a buildbot in that mode
msg403508 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-08 21:28
I can't get it to go with that option (with or without -DDEBUG, which I *think* is needed to get assert to work?), and I also don't see anything obvious in the changeset I linked. So I guess there's some other assumption that isn't holding?
msg403510 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-10-08 21:51
Nothing to do with it being Windows, or computed gotos.
I forgot to bump magic number again :(
msg403511 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-08 23:08
*facepalm* on myself, for not even thinking of that. Indeed, clearing all my .pyc files fixes it.

I think I got distracted by the error coming from one of the newly frozen modules, except because we're in tree it shouldn't be using the frozen one, so it is picking up the cached file instead.
msg403516 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-10-09 04:20
> I think we should switch back to debug builds in CI in order to catch failed assertions before they get merged.

I'm not Victor, but +1. I've been bitten by release builds not catching things, see issue44348 for example where I advocated for switching back to debug builds for Windows.

FWIW, the macOS and Ubuntu CI use debug builds too. So I don't see why Windows is special.
msg403625 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 07:45
Steve:
> Also +Victor, because I think we should switch back to debug builds in CI in order to catch failed assertions before they get merged.

Ken Jin:
> So I don't see why Windows is special.

The Python test suite is way slower on Windows when Python is built in debug mode: 19 min 41 sec (debug) instead of 12 min 19 sec (release) on Windows x64: 1.6x slower.

* https://bugs.python.org/issue45115#msg401141
* https://github.com/python/cpython/pull/28181

I would prefer to not make our workflow slower. IMO it's ok to miss a few bugs in pre-commit checks, and only catch them on Windows debug buildbots. In my experience, it happens less than once per months. It's more like 2 or 3 times per year.
msg403626 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-11 07:46
> *facepalm* on myself, for not even thinking of that. Indeed, clearing all my .pyc files fixes it.

This issue has been fixed, no? Can it be closed?

commit 5e173f5db17cbb2e3f2139a3c5ccb6b81ac59785
Author: Mark Shannon <mark@hotpy.org>
Date:   Sat Oct 9 14:17:22 2021 +0100

    Bump MAGIC_NUMBER to reflect change in JUMP_ABSOLUTE semantics. (GH-28829)
msg407984 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-12-07 23:26
Ping. This issue is marked as release blocker, is something left here?
msg407986 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-12-07 23:33
Yes, it's been fixed.

The debate about whether to test in CI with C assertions enabled or not can continue somewhere else.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89578
2021-12-07 23:33:56steve.dowersetstatus: open -> closed
resolution: fixed
messages: + msg407986

stage: test needed -> resolved
2021-12-07 23:26:56pablogsalsetmessages: + msg407984
2021-10-11 07:46:28vstinnersetmessages: + msg403626
2021-10-11 07:45:25vstinnersetmessages: + msg403625
2021-10-09 04:20:28kjsetnosy: + kj
messages: + msg403516
2021-10-08 23:08:40steve.dowersetmessages: + msg403511
2021-10-08 21:51:01Mark.Shannonsetassignee: Mark.Shannon
messages: + msg403510
2021-10-08 21:28:51steve.dowersetmessages: + msg403508
2021-10-08 20:05:57pablogsalsetmessages: + msg403499
2021-10-08 19:50:11steve.dowersetnosy: + vstinner
messages: + msg403498
2021-10-08 19:35:36steve.dowersetnosy: + Mark.Shannon, pablogsal
messages: + msg403496
2021-10-08 19:33:14steve.dowercreate