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 |
devnexen
left a comment
There was a problem hiding this comment.
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.