Skip to content

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

Closed
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:grp_mutex
Closed

vstinner wants to merge 2 commits into
python:mainfrom
vstinner:grp_mutex

Conversation

@vstinner

@vstinner vstinner commented Nov 6, 2024 •

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

Copy link
Copy Markdown
Member

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

…BcDse.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@vstinner

vstinner commented Nov 6, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

vstinner commented Nov 6, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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

2 participants