Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-127081: fix some un-thread-safe use of libc functions#132591

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
duaneg wants to merge8 commits intopython:mainfromduaneg:gh-127081

Conversation

duaneg
Copy link
Contributor

@duanegduaneg commentedApr 16, 2025
edited by bedevere-appbot
Loading

Add configure tests and defines for getservbyname_r, getservbyport_r, and getprotobyname_r. Use these if available, otherwise fallback to the thread-unsafe variants.

Add a unit test to exercise getprotobyname, which is currently untested.

TODO:

  • Are there any platforms which define the unsafe variants but not the re-entrant ones? If not we can simplify the #ifdef hell somewhat.
  • Do the re-entrant functions have the same signature on all platforms?
  • These changes follow the existing code's practice: allocate a fixed-size (and overly large) buffer, and don't properly handle the error case if it is too small. Should this be fixed? If so should existing code also be fixed?

Add configure tests and defines for getservbyname_r, getservbyport_r, andgetprotobyname_r. Use these if available, otherwise fallback to thethread-unsafe variants.Add a unit test to exercise getprotobyname, which is currently untested.TODO: - Are there any platforms which define the unsafe variants but not the   re-entrant ones? If not we can simplify the #ifdef hell somewhat. - Do the re-entrant functions have the same signature on all platforms? - These changes follow the existing code's practice: allocate a fixed-size   (and overly large) buffer, and don't properly handle the error case if it is   too small. Should this be fixed? If so should existing code also be fixed?
The libc setpwent, getpwent, and endpwent functions are not thread-safe.Protect them with mutexs in free-threading builds.
The dbm_* functions are not thread-safe, naturally. Add critical sections toprotect their use.
The getlogin function is not thread-safe: replace with getlogin_r whereavailable.Note that this function is untested (unit test is skipped with a note it causedCI failures as behaviour differs between NIX environments).
@duanegduaneg changed the titlegh-127081: use re-entrant variants of get{proto,serv}by{name,port}gh-127081: fix some un-thread-safe use of libc functionsApr 17, 2025
@picnixz
Copy link
Member

picnixz commentedApr 20, 2025
edited
Loading

Can you split the PR into multiple ones where each PR is dedicated to a single module please (dbm and gdbm can be put together)? it's easier to revert commits if needs arise and we can also merge them separately.

@duaneg
Copy link
ContributorAuthor

Can you split the PR into multiple ones where each PR is dedicated to a single module please (dbm and gdbm can be put together)? it's easier to revert commits if needs arise and we can also merge them separately.

Definitely! Good suggestion, thanks.

picnixz reacted with thumbs up emoji

@duanegduaneg closed thisApr 20, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@erlend-aaslanderlend-aaslandAwaiting requested review from erlend-aaslanderlend-aasland is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

@serhiy-storchakaserhiy-storchakaAwaiting requested review from serhiy-storchakaserhiy-storchaka is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@duaneg@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp