Skip to content

fix startup with the default ffi.enable=preload - #292

Merged
jcupitt merged 1 commit into
libvips:masterfrom
wadakatu:fix-ffi-enable-check
Nov 1, 2026
Merged

jcupitt merged 1 commit into
libvips:masterfrom
wadakatu:fix-ffi-enable-check

Conversation

@wadakatu

Copy link
Copy Markdown
Contributor

On a stock PHP install ffi.enable is preload, and since #287 php-vips refuses to start there even though FFI works:

$ php -r 'var_export(ini_get("ffi.enable"));'
'preload'
$ php -r 'require "vendor/autoload.php"; echo Jcupitt\Vips\Config::version(), "\n";'
Fatal error: Uncaught Jcupitt\Vips\Exception: ffi.enable set to 'preload', not 'true'
$ php -r 'FFI::cdef("int puts(const char *);", "libc.so.6")->puts("FFI works");'
FFI works

With ffi.enable=preload, PHP allows an FFI call if the SAPI is cli, or the caller was compiled during opcache.preload, or the preload script is running (zend_ffi_validate_api_restriction() in ext/ffi/ffi.c). Only the SAPI is visible from PHP, so no check on the ini value can be right: the same value works under php -r and is refused under php -S.

ffi.enable is INI_SYSTEM, so StartupTest runs a second PHP process with -d ffi.enable=preload and -d ffi.enable=0. Both tests fail on master. phpunit.xml now uses the default Test.php suffix so the helper script is not picked up as a test.

@wadakatu
wadakatu force-pushed the fix-ffi-enable-check branch from 6d163e7 to 381d619 Compare October 5, 2026 07:57
@wadakatu
wadakatu force-pushed the fix-ffi-enable-check branch from 381d619 to b994c01 Compare November 1, 2026 09:27
@wadakatu

wadakatu commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@jcupitt
Hi.
I would appreciate it if you could review my PR whenever you are free.
Please tell me if there are any blockers that prevent you from reviewing.
Thanks.

@jcupitt

jcupitt commented Nov 1, 2026

Copy link
Copy Markdown
Member

Sorry @wadakatu, this keeps dropping off my radar. I'll review and merge now.

@jcupitt
jcupitt merged commit 7f10425 into libvips:master Nov 1, 2026
6 checks passed
@jcupitt

jcupitt commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks for working on this, and thanks for reminding me. I've been stretched a bit thin the last few months :(

@wadakatu
wadakatu deleted the fix-ffi-enable-check branch November 1, 2026 16:45
@wadakatu

wadakatu commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@jcupitt
Thank you for merging this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants