[php-src] Issue #11818: macOS now crash fork() process instead of just warning

From: Date: Sat, 29 Jul 2023 11:47:57 +0000
Subject: [php-src] Issue #11818: macOS now crash fork() process instead of just warning
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245063@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11818 Author: askdkc ### Description The latest macOS update has begun terminating certain fork() processes under specific circumstances. This is evidenced by the following screenshots and error logs <img width="1128" alt="255328277-612559bd-d64e-4231-a6c5-5a60c9ba703a" src="https://github.com/php/php-src/assets/7894265/feb2ef77-23fa-45d8-b4be-a977cfccd45c"> In the Nginx Error Log, we find multiple instances of "upstream prematurely closed connection" errors. The PHP Error Log indicates warnings about "__NSPlaceholderDate initialize" possibly running in another thread when fork() was invoked, and subsequently, child processes exiting prematurely. - Nginx Error Log ```txt [error] 1957#0: *2 upstream prematurely closed connection [error] 50639#0: *77 upstream prematurely closed connection [error] 28667#0: *16 upstream prematurely closed connection ``` - PHP Error Log ```txt [27-Jul-2023 09:49:38] NOTICE: ready to handle connections [27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 said into stderr: "objc[54119]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called." [27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 said into stderr: "objc[54119]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug." [27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 exited on signal 6 (SIGABRT) after 9.676681 seconds from start [27-Jul-2023 09:49:48] NOTICE: [pool valet] child 54693 started [27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 said into stderr: "objc[54120]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called." [27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 said into stderr: "objc[54120]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug." [27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 exited on signal 6 (SIGABRT) after 50.322856 seconds from start [27-Jul-2023 09:50:29] NOTICE: [pool valet] child 54703 started ``` ## How to reproduce Follow this step: https://github.com/laravel/valet/issues/1433#issuecomment-1653063304 ## Work Around (so far) Rails users faced a similar issue a few years ago (refer to [rails/rails#38560](https://github.com/rails/rails/issues/38560)) and resolved it by introducing the environment variable export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES. macOS php installed using Homebrew can achieve this by adding ```xml <key>EnvironmentVariables</key> <dict> <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key> <string>YES</string> </dict> ``` to PHP LauchDaemon plist homebrew.mxcl.php.plist. But ultimately it should be fixed in PHP itself. ### PHP Version PHP 8.2.8 ### Operating System macOS 13.5

« previous php.bugs (#245063) next »