Report a missing executable on glibc older than 2.24 - #106
Open
bernardladenthin wants to merge 3 commits into
Open
Report a missing executable on glibc older than 2.24#106bernardladenthin wants to merge 3 commits into
bernardladenthin wants to merge 3 commits into
Conversation
posix_spawn_file_actions_addchdir_np arrived in glibc 2.29, so subprocess_create_ex fails to compile and link on older systems such as manylinux2014. Add a SUBPROCESS_HAVE_CWD probe, report a requested cwd as ENOSYS where the call is unavailable, and skip the cwd test there.
musl gained posix_spawn_file_actions_addchdir_np in 1.1.24 but exposes no version macro, so the detection cannot cover older releases. Skip it when the macro is already defined, letting those users set it themselves.
Merged
2 tasks
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #104 — without it the library does not build on any glibc old enough to show
this problem.
Problem
On glibc older than 2.24,
posix_spawndoes not report a failedexecback to thecaller.
subprocess_createtherefore returns success for an executable that does notexist, and the child quietly exits with 127. Two tests in the suite cover exactly this
and fail on such systems:
Across the 9 language modes that is 18 failures on manylinux2014 (glibc 2.17). They only
became visible with #104, because before that the library did not build there at all.
The behaviour is glibc's, not this library's — a standalone probe with a missing binary:
posix_spawnrc=0, child exits 127rc=0, child exits 127rc=2(ENOENT)rc=2(ENOENT)Fix
Add a
SUBPROCESS_SPAWN_REPORTS_EXEC_ERRORSprobe alongsideSUBPROCESS_HAVE_CWD, andwhere it is 0, check the executable with
access(..., X_OK)before spawning.errnoandthe returned
subprocess_error_ethen match what every supported glibc produces.Behaviour on glibc 2.24 and newer, and on every non-glibc platform, is unchanged — the
check is not compiled there at all.
Limitations
Only the explicit-path branch is covered.
posix_spawnpresolves the executablethrough
PATH, which would mean reimplementing that search — including empty entriesmeaning "current directory" and the
ENOEXECshell fallback. Measured on glibc 2.17 withthis patch applied:
Nobody is worse off than before, where both cases were silent, but the
PATHcase remainswrong on those systems. Happy to extend it if you would rather have the full search.
There is a TOCTOU window between
accessandposix_spawn. On a platform whoseposix_spawncannot report the failure at all, a best-effort check seemed better thannone — but it is a best-effort check, not a guarantee.
Testing
AlmaLinux 8 is the interesting control: glibc 2.28 is old enough to lack
addchdir_npbut new enough to report exec failures, so the probe must be 0 for onefeature and 1 for the other — and nothing there changes.