Skip to content

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Sep 1, 2025

The bug was that we used the wrong name list to get __conditional_annotations__, which caused us to emit a SET_ADD that was adding to something that wasn't a set. This manifested as a hang on debug builds and a crash on release builds for whatever reason, but the issue became more apparent when I added an assertion to setobject.c to make sure we were only adding to sets.

@Fidget-Spinner
Copy link
Member

Do you need to bump the pyc magic number as well? I forgot whether bytecode invalidation matters here.

@markshannon
Copy link
Member

The changes look correct to me, but I've not looked that closely at the conditional annotation code.
This will need a magic number bump as the old pycs could cause crashes.

@vstinner
Copy link
Member

vstinner commented Sep 9, 2025

This will need a magic number bump as the old pycs could cause crashes.

@JelleZijlstra: Can you update the magic number (in Include/internal/pycore_magic_number.h) please?

@JelleZijlstra
Copy link
Member Author

Done

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. The changes does fix the crash and the added tests check for non-regression.

@markshannon markshannon added the needs backport to 3.14 bugs and security fixes label Sep 10, 2025
@vstinner vstinner merged commit 7a6fd4a into python:main Sep 10, 2025
51 checks passed
@miss-islington-app
Copy link

Thanks @JelleZijlstra for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @JelleZijlstra and @vstinner, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 7a6fd4a45deee23b827bf8e32bde172e14921ed6 3.14

vstinner pushed a commit to vstinner/cpython that referenced this pull request Sep 10, 2025
@bedevere-app
Copy link

bedevere-app bot commented Sep 10, 2025

GH-138749 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 Sep 10, 2025
@vstinner
Copy link
Member

Merged, thanks @JelleZijlstra. I wrote a backport to 3.14 (I adapted the magic number for 3.14).

@JelleZijlstra JelleZijlstra deleted the fix138349 branch September 10, 2025 14:15
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…d listcomp (#138363) (#138749)

* gh-138349: Fix crash when combining module-level annotation and listcomp (#138363)

(cherry picked from commit 7a6fd4a)

---------

Co-authored-by: Jelle Zijlstra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants