Opened 12 months ago
Last modified 7 months ago
#68817 assigned defect
php81-fpm: crashes constantly
Reported by: | miken32 (Michael Newton) | Owned by: | ryandesign (Ryan Carsten Schmidt) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | sonoma | Cc: | |
Port: | php |
Description
This is a known issue I think since macOS 14 that affects a lot of software using fork()
and Objective C libraries (or something like that, I am not a low-level programmer.)
objc[70634]: +[__SwiftNativeNSStringBase initialize] may have been in progress in another thread when fork() was called. objc[70634]: +[__SwiftNativeNSStringBase 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.
There is an open ticket with PHP but it doesn't sound like it will get fixed anytime soon.
Workaround is setting an environment variable by changing the launch daemon to look like this:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" > <plist version='1.0'> <dict> <key>EnvironmentVariables</key> <dict> <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key> <string>YES</string> </dict> <key>Label</key><string>org.macports.php81-fpm</string> <key>ProgramArguments</key> <array> <string>/opt/local/bin/daemondo</string> <string>--label=php81-fpm</string> <string>--start-cmd</string> <string>/opt/local/sbin/php-fpm81</string> <string>;</string> <string>--pid=exec</string> </array> <key>Disabled</key><true/> <key>KeepAlive</key><true/> </dict> </plist>
This may be considered unsafe by some, so maybe it should be done as a variant?
Change History (3)
comment:1 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)
Keywords: | sonoma added |
---|---|
Port: | php added; php-fpm removed |
Summary: | PHP FPM crashes constantly → php81-fpm: crashes constantly |
comment:2 Changed 11 months ago by ryandesign (Ryan Carsten Schmidt)
Replying to miken32:
There is an open ticket with PHP but it doesn't sound like it will get fixed anytime soon.
Having now read that entire issue, the mentions there of gettext and the Foundation framework make me wonder updating to gettext 0.22.x helps, since gettext 0.22.x introduces the fix for a known crashing issue on Sonoma by linking with the Foundation framework.
comment:3 Changed 7 months ago by miken32 (Michael Newton)
Just a quick note to say that no, gettext 0.22 didn't help. I'm currently on gettext @0.22.5 (devel)
and php83-fpm @8.3.6 (lang, www)
with the same issue and resolution.
It pops up elsewhere as well, eg typing sudo ls /
followed by Tab causes bash-completion
to barf somehow (it's something to do with sudo
; works fine otherwise.)
mike ~ ❱❱❱ sudo ls /objc[43923]: +[__SwiftNativeNSStringBase initialize] may have been in progress in another thread when fork() was called. objc[43923]: +[__SwiftNativeNSStringBase 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. Abort trap: 6 Password:
A quick Google search of
OBJC_DISABLE_INITIALIZE_FORK_SAFETY
finds results from years ago and that this environment variable and the OS feature it disables have been around since macOS High Sierra. But I've definitely run php-fpm under High Sierra and Catalina and Monterey. And you say this problem started for you in Sonoma. I wonder what changed in Sonoma.If the software crashes without adding the environment variable on Sonoma and later, then I think I should add it unconditionally on Sonoma and later to fix the crash rather than use a variant.