FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-127081: lock non-re-entrant `*pwent` calls by duaneg · Pull Request #132748 · python/cpython · GitHub

Repository navigation

gh-127081: lock non-re-entrant *pwent calls - #132748

Merged
kumaraditya303 merged 6 commits into
python:mainfrom
duaneg:gh-127081-pwd
May 22, 2025
Merged

kumaraditya303 merged 6 commits into
python:mainfrom
duaneg:gh-127081-pwd

Conversation

duaneg commented Apr 20, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

The libc setpwent, getpwent, and endpwent functions are not thread-safe. Protect them with mutexs in free-threading builds.

The libc setpwent, getpwent, and endpwent functions are not thread-safe.
Protect them with mutexs in free-threading builds.
picnixz changed the title gh-127081: lock non-re-entrant *pwent calls gh-127081: lock non-re-entrant *pwent calls Apr 20, 2025

ZeroIntensity 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We need a critical section here. Py_CLEAR and Py_DECREF are re-entrant (as in, they can invoke the eval loop), so a mutex is prone to lock-ordering or re-entrancy deadlocks.

Copy link
Copy Markdown
Member

Actually, sorry, we need to fix subinterpreter thread-safety here too. We can't do that with a critical section. Could you adjust the mutex to go over solely the libc calls?

Comment thread Modules/pwdmodule.c
Comment thread Modules/pwdmodule.c Outdated

duaneg commented Apr 20, 2025

Copy link
Copy Markdown
Contributor Author

Py_CLEAR and Py_DECREF are re-entrant...Could you adjust the mutex to go over solely the libc calls?

Hmm, yeah, good point. I guess we can just defer the decrefs until exit.

Comment thread Modules/pwdmodule.c Outdated
Comment thread Modules/pwdmodule.c Outdated
Comment thread Modules/pwdmodule.c Outdated
kumaraditya303 self-requested a review May 21, 2025 16:51
Comment thread Modules/pwdmodule.c
… they are

strongly referenced by that, so we can dec-ref them safely.
Comment thread Modules/pwdmodule.c Outdated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL