Skip to content

gh-154014: Initialize cold executor vm_data fields#154142

Open
BHUVANSH855 wants to merge 7 commits into
python:mainfrom
BHUVANSH855:fix-154014-jit-vm-data-assert
Open

gh-154014: Initialize cold executor vm_data fields#154142
BHUVANSH855 wants to merge 7 commits into
python:mainfrom
BHUVANSH855:fix-154014-jit-vm-data-assert

Conversation

@BHUVANSH855

Copy link
Copy Markdown

Issue

Fixes gh-154014.

Summary

make_cold_executor() allocates cold executors directly via
allocate_executor() and bypasses _Py_ExecutorInit(). As a result,
vm_data.valid and vm_data.pending_deletion remain uninitialized.

During interpreter shutdown, interpreter_clear() asserts that
cold->vm_data.valid is true, causing assertion failures when CPython is
built with --enable-experimental-jit --with-assertions.

This change initializes the required vm_data fields for cold executors,
restoring the expected invariant during shutdown.

Testing

Reproduced the original crash reported in the issue using:

./configure --enable-experimental-jit --with-assertions
make -j$(nproc)

Before this change, _bootstrap_python aborted with:

Assertion `cold->vm_data.valid' failed.

After this change:

  • make -j$(nproc) completes successfully.
  • The full CPython regression test suite passes.

@bedevere-app

bedevere-app Bot commented Jul 19, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Fidget-Spinner Fidget-Spinner 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.

Looks good, just needs style cleanups.

Comment thread Python/optimizer.c
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
Comment thread Python/optimizer.c Outdated
@Fidget-Spinner

Copy link
Copy Markdown
Member

Please add a news entry as well, and a test reproducer in Lib/test/test_capi/test_opt.py.

@bedevere-app

bedevere-app Bot commented Jul 19, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@BHUVANSH855

Copy link
Copy Markdown
Author

Thanks for the review @Fidget-Spinner

I've addressed the requested changes:

  • removed the stray formatting changes,
  • added a NEWS entry,
  • added a regression test in Lib/test/test_capi/test_opt.py.

The CI is now running on the updated branch. I'd appreciate another look when you have a chance. Thanks!

Comment thread Python/optimizer.c
@BHUVANSH855
BHUVANSH855 requested a review from cocolato July 20, 2026 12:30

@cocolato cocolato 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.

we can release unregistered cold executors directly

Comment thread Python/optimizer.c Outdated
@BHUVANSH855
BHUVANSH855 requested a review from cocolato July 20, 2026 12:47
@cocolato

Copy link
Copy Markdown
Member

Thanks! let's wait for Ken Jin's review :)

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.

JIT build crashes on assertions (since 3.15): Python/pystate.c:925: interpreter_clear: Assertion 'cold->vm_data.valid' failed.

3 participants