Skip to content

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

Open
wadakatu wants to merge 1 commit into
libvips:masterfrom
wadakatu:fix-ffi-enable-check
Open

wadakatu wants to merge 1 commit into
libvips:masterfrom
wadakatu:fix-ffi-enable-check

Conversation

@wadakatu

Copy link
Copy Markdown

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.

This branch has not been deployed

No deployments
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.

1 participant