File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -243,10 +243,6 @@ private static function init(): void
243243 if (!ini_get ('ffi.enable ' )) {
244244 throw new Exception ("ffi.enable not set to 'true' " );
245245 }
246- if (version_compare (PHP_VERSION , '8.3 ' , '>= ' ) &&
247- ini_get ('zend.max_allowed_stack_size ' ) != '-1 ' ) {
248- throw new Exception ("zend.max_allowed_stack_size not set to '-1' " );
249- }
250246
251247 $ vips_libname = self ::libraryName ("libvips " , 42 );
252248 if (PHP_OS_FAMILY === "Windows " ) {
Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ abstract class GObject
6060 */
6161 private CData $ pointer ;
6262
63+ /**
64+ * libvips executes FFI callbacks off the main thread and this confuses
65+ * the stack limit checks available since PHP 8.3.0. We need to check
66+ * if `zend.max_allowed_stack_size` is set to `-1`.
67+ * See: https://github.com/libvips/php-vips/pull/237.
68+ */
69+ private static bool $ check_max_stack_size = true ;
70+
6371 /**
6472 * Wrap a GObject around an underlying vips resource. The GObject takes
6573 * ownership of the pointer and will unref it on finalize.
@@ -104,6 +112,16 @@ public function unref(): void
104112 */
105113 public function signalConnect (string $ name , callable $ callback ): void
106114 {
115+ if (self ::$ check_max_stack_size ) {
116+ $ max_allowed_stack_size = ini_get ('zend.max_allowed_stack_size ' );
117+ if ($ max_allowed_stack_size !== false &&
118+ $ max_allowed_stack_size !== '-1 ' ) {
119+ throw new Exception ("signalConnect() requires zend.max_allowed_stack_size set to '-1' " );
120+ }
121+
122+ self ::$ check_max_stack_size = false ;
123+ }
124+
107125 $ marshaler = self ::getMarshaler ($ name , $ callback );
108126 if ($ marshaler === null ) {
109127 throw new Exception ("unsupported signal $ name " );
You can’t perform that action at this time.
0 commit comments