Skip to content
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

flowgraph optimize_cfg Assertion for if-else-expression with if-else-expression as condition #109889

Closed
15r10nk opened this issue Sep 26, 2023 · 3 comments · Fixed by #109987
Closed
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@15r10nk
Copy link
Contributor

15r10nk commented Sep 26, 2023

Bug report

Bug description:

a if (1 if b else c) else d

output (Python 3.12.0rc3+):

python: Python/flowgraph.c:1598: optimize_cfg: Assertion `no_redundant_nops(g)' failed.

tested with the current 3.12 branch (538f505)

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

@15r10nk 15r10nk added the type-bug An unexpected behavior, bug, or error label Sep 26, 2023
@AA-Turner
Copy link
Member

cc: @iritkatriel

@AA-Turner AA-Turner added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump 3.12 bugs and security fixes 3.13 bugs and security fixes labels Sep 26, 2023
@AlexWaygood AlexWaygood removed the type-bug An unexpected behavior, bug, or error label Sep 26, 2023
@iritkatriel
Copy link
Member

iritkatriel commented Sep 26, 2023

The optimizer removes NOPs which are redundant (don't have important line number info attached). But there is a bug where it misses the case where there is a basic block that contains a single such NOP (and nothing else).

This is not a correctness issue, it's only an optimization failing. I will make a PR for 3.12 to just remove the assertion. In 3.13 I will fix this optimization.

@iritkatriel
Copy link
Member

I will make a PR for 3.12 to just remove the assertion. In 3.13 I will fix this optimization.

I mean remove the assertion in 3.12.0. We can fix in 3.12.1.

iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 26, 2023
Yhg1s pushed a commit that referenced this issue Sep 26, 2023
…ion of a redundant NOP (#109899)

* [3.12] gh-109889: comment out assertion indicating a failed optimization of a redundant NOP

* comment out the function to avoid warnings on it being unused
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 27, 2023
…o lineno when looking for the next instruction's lineno
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 27, 2023
…o lineno when looking for the next instruction's lineno
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 27, 2023
…o lineno when looking for the next instruction's lineno
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 27, 2023
…o lineno when looking for the next instruction's lineno
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 28, 2023
iritkatriel added a commit that referenced this issue Sep 28, 2023
…ith no lineno when looking for the next instruction's lineno (#109987)
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 28, 2023
…NOPs with no lineno when looking for the next instruction's lineno (pythonGH-109987)

(cherry picked from commit f580edc)

Co-authored-by: Irit Katriel <[email protected]>
csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 29, 2023
…NOPs with no lineno when looking for the next instruction's lineno (python#109987)
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
… NOPs with no lineno when looking for the next instruction's lineno (GH-109987) (#110048)

gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (GH-109987)
(cherry picked from commit f580edc)

Co-authored-by: Irit Katriel <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…NOPs with no lineno when looking for the next instruction's lineno (python#109987)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
5 participants
@iritkatriel @AA-Turner @15r10nk @AlexWaygood and others