Skip to content

gh-151112: Move an assert that may fail in cfg_builder_check#151153

Merged
StanFromIreland merged 1 commit into
python:mainfrom
StanFromIreland:cfg_builder_check
Jun 11, 2026
Merged

gh-151112: Move an assert that may fail in cfg_builder_check#151153
StanFromIreland merged 1 commit into
python:mainfrom
StanFromIreland:cfg_builder_check

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Jun 9, 2026

Copy link
Copy Markdown
Member

Also found with the same reproducer, just setting nomemory at a different time. In _PyCfg_FromInstructionSequence if _PyCfgBuilder_Addop fails on the first instruction, it jumps to error and calls _PyCfgBuilder_Free(g). The entry block is still empty, but cfg_builder_check asserts g_entryblock->b_iused > 0.

If you want to reproduce, you'll have to play around a little with the start/stop for nomemory, but for me it's:

./python -c 'import _testcapi

compile("pass", "<warmup>", "single")
_testcapi.set_nomemory(40, 41)
try:
    compile("pass", "<trigger>", "single")
except MemoryError:
    pass
first = bytes(128)
second = bytes(128)'
python: Python/flowgraph.c:407: cfg_builder_check: Assertion `g->g_entryblock->b_iused > 0' failed.
Aborted                    (core dumped) ./python -c 'import _testcapi

Debug only so skipping news.

@iritkatriel iritkatriel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StanFromIreland StanFromIreland added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 10, 2026
@StanFromIreland StanFromIreland merged commit 2d33810 into python:main Jun 11, 2026
66 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@StanFromIreland StanFromIreland deleted the cfg_builder_check branch June 11, 2026 09:16
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151313 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151314 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151315 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 11, 2026
StanFromIreland added a commit that referenced this pull request Jun 11, 2026
…k` (GH-151153) (#151315)

(cherry picked from commit 2d33810)

Co-authored-by: Stan Ulbrych <stan@python.org>
StanFromIreland added a commit that referenced this pull request Jun 11, 2026
…k` (GH-151153)

(cherry picked from commit 2d33810)

Co-authored-by: Stan Ulbrych <stan@python.org>
StanFromIreland added a commit that referenced this pull request Jun 11, 2026
…k` (GH-151153) (#151313)

(cherry picked from commit 2d33810)

Co-authored-by: Stan Ulbrych <stan@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants