Skip to content

Commit 81d2281

Browse files
committed
check max_allowed_stack_size during startup
see #237
1 parent c686398 commit 81d2281

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ server can use it to call any native library they have access to.
5353
Of course if attackers are running their own PHP code on your webserver you
5454
are probably already toast, unfortunately.
5555

56+
Finally, on php 8.3 and later you need to disable stack overflow
57+
tests. php-vips executes FFI callbacks off the main thread and this confuses
58+
those checks, at least in php 8.3.0.
59+
60+
Add:
61+
62+
```
63+
zend.max_allowed_stack_size=-1
64+
```
65+
66+
To your `php.ini`.
67+
5668
### Example
5769

5870
```php

src/FFI.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,17 @@ private static function init(): void
236236
return;
237237
}
238238

239-
// the two usual installation problems
239+
// detect the most common installation problems
240240
if (!extension_loaded('ffi')) {
241241
throw new Exception('FFI extension not loaded');
242242
}
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+
}
246250

247251
$vips_libname = self::libraryName("libvips", 42);
248252
if (PHP_OS_FAMILY === "Windows") {

0 commit comments

Comments
 (0)