-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Fix usage of reentrant functions in ext/posix #13921
Conversation
- It's not necessarily an error of sysconf(_SC_GETPW_R_SIZE_MAX) returns -1, as specified by posix (and the musl implementation always returns -1). Pick an initial buffer size in this case. - Reentrant variants return an error number an may not set errno - Implement retry logic for ttyname_r() - Fix retry logic for getpwnam_r() (pw would be NULL after the first try) - Test retry logic by setting the initial buffer size to 1 in debug builds
I think a somewhat similar PR was started earlier but maybe I confuse. |
Indeed, there appears to be some overlap with #13922 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Do you really want to keep the debug part ? :)
Thank you! Yes, this ensures that the retry code paths are tested. This doesn't negatively impact the duration of the test suite. |
* PHP-8.2: [ci skip] NEWS Fix usage of reentrant functions in ext/posix (#13921)
* PHP-8.3: [ci skip] NEWS [ci skip] NEWS Fix usage of reentrant functions in ext/posix (#13921)
Is this responsible for the failures in nightly? https://github.com/php/php-src/actions/runs/8682420096/job/23806945143 |
It's possible. I will check! |
The nightly failures are definitely related to this patch. |
Tests for these functions would fail under musl due to
sysconf(_SC_GETPW_R_SIZE_MAX)
returning -1 (which is allowed by the standard). The test suite passed on other platforms, but these functions could fail under unusual conditions. Setting buflen to 1 ensures that the retry logic is tested.