-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Python/flowgraph.c:1813: void insert_superinstructions(cfg_builder *): Assertion `no_redundant_nops(g)' failed #113054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How can I reproduce this? |
I believe |
Also:
|
@pablogsal Is it ok that this even gets past the parser?
|
Unfortunately yes, we discussed this in the past and we resolved to show a warning but technically disallowing it it's backwards incompatible :( I will try to find the issue when I am back home if someone doesn't find it first |
In the docs we say: https://docs.python.org/3/reference/lexical_analysis.html#whitespace-between-tokens
|
If we put aside the issue of whitespace, is this valid?
|
I guess that's
|
It looks like you don't need any of the weird (lack of) whitespace stuff to trigger an assertion: Running Debug|x64 interpreter...
Python 3.13.0a2+ (heads/main:cf6110ba13, Dec 7 2023, 20:00:55) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> if 5 if 5 else T: 0
...
Assertion failed: no_redundant_nops(g), file C:\Users\alexw\coding\cpython\Python\flowgraph.c, line 1813 (And it still triggers with the parens, FWIW): >>> if (5 if 5 else T): 0
...
Assertion failed: no_redundant_nops(g), file C:\Users\alexw\coding\cpython\Python\flowgraph.c, line 1813 |
The issue is that this code produces at some point these three basic blocks:
2 is redundant because it has no line number. Once it is removed, 1 becomes redundant because it's a NOP that has the same line number as the next instruction. But the way the algorithm is implemented, this is checked before 2 is removed, so we don't remove 1. Then the assertion fails. This is not a correctness bug (without the assertion we would just have another NOP in the code). I'll think how to fix this. |
… line number by a NOP
The NOP with no line number came from a redundant jump with no line number. So I made a change to remove such jumps instead of replacing them by NOPs that will be removed later. #113139 |
3.12 doesn't have this issue as far as I can tell. |
… line number by a NOP (python#113139)
… line number by a NOP (python#113139)
… line number by a NOP (python#113139)
Bug report
Bug description:
The
fuzz_pycompile
identified an assertion failure:Reproducer (note that the first two bytes are metadata for the fuzzer):
cc: @bradlarsen
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: