libvips / php-vips

php binding for libvips
MIT License
615 stars 25 forks source link

Crashes webserver when used with apache and mod_php #214

Open ausi opened 1 year ago

ausi commented 1 year ago

I’m using Apache 2.4.57 with PHP 8.1.21 loaded as mod_php (PHP SAPI apache2handler).

Using vips via the command line works as expected, but running the same code on the webserver crashes with the following error:

objc[30622]: +[NSCheapMutableString initialize] may have been in progress in another thread when fork() was called.
objc[30622]: +[NSCheapMutableString 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.
[Wed Jul 26 22:52:34.952832 2023] [core:notice] [pid 28824] AH00052: child pid 30622 exit signal Abort trap (6)
jcupitt commented 1 year ago

Hi @ausi,

This is an issue on macOS, is that your platform? It's been investigated for ruby-vips:

https://github.com/libvips/ruby-vips/issues/155

Possibly, starting php-vips earlier could fix this.

ausi commented 1 year ago

This is an issue on macOS, is that your platform?

Yes:

$ uname -a
Darwin ….local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64

Possibly, starting php-vips earlier could fix this.

I don’t know what that means ☺️

adamkiss commented 1 year ago

I have exactly the same problem with nginx 1.23.3 and PHP 8.2.10

The same exact code runs via CLI, but just kills the php-fpm thread it runs on.

From phpinfo();

PHP Version => 8.2.10
System => Darwin km.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64
lemontango commented 1 year ago

I recently installed PHP 8.2 and Apache 2.4 with Homebrew on OS X Sonoma.

Running php-libvips from Terminal works fine, but when running it via Apache the server immediately drops connection and crashes.

I see this in the Apache-log: objc[8822]: +[NSCheapMutableString 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.

Any advice would be greatly appreciated.

jcupitt commented 1 year ago

Did you read the ruby-vips issue linked above? The problem is with dynamic libraries on macos loading after a fork(). You need to somehow force the library to load earlier in process startup, or perhaps run your server in a VM.