Fix macOS posix_spawn_file_actions_addchdir availability handling#21722
Fix macOS posix_spawn_file_actions_addchdir availability handling#21722arshidkv12 wants to merge 6 commits into
Conversation
| /* The non-_np variant is in macOS 26 (and _np deprecated) */ | ||
| #ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR | ||
| #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir | ||
| static inline int php_spawn_addchdir( |
There was a problem hiding this comment.
I think this might be able to be simplified by checking __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__/__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ instead, since we don't need any real runtime differences, it's just a symbol name, and the old one is unlikely to go away right now even if it's deprecated. It should respect -mmacosx-version-min as well.
|
Still triggers the deprecation on 26; I think you need the |
|
Builds with |
|
Please check it |
|
I can reproduce this, and tested this PR's patch locally: it fixes the crash for me. Environment:
➜ printf '#include <AvailabilityMacros.h>\nMAC_OS_X_VERSION_MIN_REQUIRED\n' | cc -E - | tail -n 1
150000➜ nm -gU /usr/lib/system/libsystem_kernel.dylib | rg posix_spawn_file_actions_addchdir
0000000000015318 T _posix_spawn_file_actions_addchdir_np➜ nm -m sapi/cli/php | grep posix_spawn_file_actions_addchdir
(undefined) external _posix_spawn_file_actions_addchdir_np (from libSystem)Agent FeedbackI first hit this through the PHPT runner, which segfaulted immediately, but I was also able to reduce it to a minimal <?php
echo "before\n";
$spec = [
0 => ["pipe", "r"],
1 => ["pipe", "w"],
2 => ["pipe", "w"],
];
proc_open(["/bin/echo", "ok"], $spec, $pipes, getcwd(), []);
echo "after\n";With current upstream beforeand then segfaults. From what I can tell, this started after commit c3a1214 (ext/standard: Use posix_spawn_file_actions_addchdir when available), which prefers posix_spawn_file_actions_addchdir() when the SDK advertises it. With this PR's fix applied and rebuilt it works. On my setup that selects
|
#21720