Skip to content

gh-126316: Use mutexes in the grp module #126504

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

Closed
wants to merge 2 commits into from
Closed

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 6, 2024

@vstinner vstinner added the needs backport to 3.13 bugs and security fixes label Nov 6, 2024
@bedevere-app bedevere-app bot mentioned this pull request Nov 6, 2024
@ZeroIntensity
Copy link
Member

Actually, we'll need a separate fix for subinterpreters on 3.12, because there's no PyMutex there.

@vstinner
Copy link
Member Author

vstinner commented Nov 6, 2024

Actually, we'll need a separate fix for subinterpreters on 3.12, because there's no PyMutex there.

The regular build (not Free Threaded build) is not affected by #126316 since function calls are serialized by the GIL.

@ZeroIntensity
Copy link
Member

Yeah, but a subinterpreter can have its own GIL, so if these functions aren't thread safe on a system level, then it won't be thread safe across multiple interpreters. I think we just need to add a Py_mod_multiple_interpreters module slot with Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED, to indicate that subinterpreters need to use a shared GIL to use the module.

@vstinner
Copy link
Member Author

vstinner commented Nov 6, 2024

Yeah, but a subinterpreter can have its own GIL, so if these functions aren't thread safe on a system level, then it won't be thread safe across multiple interpreters.

My change only fix free-threaded build. Should I also change the regular build for this use case?

@ZeroIntensity
Copy link
Member

On second thought, I think we should address subinterpreters in another PR for backporting reasons. The fix is what I said with the module slot above.

@vstinner
Copy link
Member Author

#127055 was merged instead. I close this issue.

@vstinner vstinner closed this Nov 21, 2024
@vstinner vstinner deleted the grp_mutex branch November 21, 2024 14:48
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