Description
We're trying to use the latest version from Packagist (2.0.1) on Debian 11 with PHP 7.4. Unfortunately, we ran into some issues where the FPM processes would freeze or crash when calling into libvips.
A simple test script calling \Jcupitt\Vips\Image::newFromArray()
is sufficient to reproduce the issue. It works fine when running the script multiple times from the command line, but when running in PHP-FPM, it only works the first time, and subsequent requests will freeze or crash the PHP process.
The issue appears to have something to do with libvips and the related GLib types being initialized multiple times. On the CLI, a fresh PHP process is created for each run of the script, but PHP-FPM uses long running processes, and a subsequent request may cause libvips to be initialized again.
We have a repository containing a docker-compose setup which may be used to reproduce this bug. Simply running docker-compose up
in the cloned repository, then navigating to http://localhost:8080/
should display a var_dump()
of an Image
object. Refreshing the page causes the FPM process to hang, eventually resulting in a HTTP 504 Gateway Timeout error. On the command line, the following errors appear:
php_1 | (.:7): GLib-GObject-WARNING **: 11:47:53.920: cannot register existing type 'VipsObject'
php_1 | (.:7): GLib-CRITICAL **: 11:47:53.920: g_once_init_leave: assertion 'result != 0' failed
php_1 | (.:7): GLib-GObject-CRITICAL **: 11:47:53.920: g_type_register_static: assertion 'parent_type > 0' failed
php_1 | (.:7): GLib-CRITICAL **: 11:47:53.920: g_once_init_leave: assertion 'result != 0' failed