com php-src: Handle bailouts during preload linking: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 06.phpt
ext/opcache/tests/preload_inheritance_error .inc ext/opcache/tests/preload_inheritance_error_ind .inc

From: Date: Fri, 15 Feb 2019 15:56:32 +0000
Subject: com php-src: Handle bailouts during preload linking: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 06.phpt
ext/opcache/tests/preload_inheritance_error .inc ext/opcache/tests/preload_inheritance_error_ind .inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104671@lists.php.net to get a copy of this message
Commit: 92fae00ee0674c7fef830b01aa474d8bc684bf74 Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 16:56:32 +0100 Parents: a9497cecf3a76b3264ed0807023cd59e9bcf6f23 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=92fae00ee0674c7fef830b01aa474d8bc684bf74 Log: Handle bailouts during preload linking Changed paths: M ext/opcache/ZendAccelerator.c A ext/opcache/tests/preload_006.phpt A ext/opcache/tests/preload_inheritance_error.inc A ext/opcache/tests/preload_inheritance_error_ind.inc Diff: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f30b675..f9e67ef 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3850,7 +3850,14 @@ static int accel_preload(const char *config) zend_hash_graceful_reverse_destroy(&EG(symbol_table)); zend_hash_init(&EG(symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); - preload_link(); + /* Inheritance errors may be thrown during linking */ + zend_try { + preload_link(); + } zend_catch { + ret = FAILURE; + goto finish; + } zend_end_try(); + preload_remove_empty_includes(); /* Don't preload constants */ @@ -3940,6 +3947,7 @@ static int accel_preload(const char *config) zend_shared_alloc_destroy_xlat_table(); } +finish: zend_hash_destroy(preload_scripts); efree(preload_scripts); preload_scripts = NULL; diff --git a/ext/opcache/tests/preload_006.phpt b/ext/opcache/tests/preload_006.phpt new file mode 100644 index 0000000..925b9a6 --- /dev/null +++ b/ext/opcache/tests/preload_006.phpt @@ -0,0 +1,15 @@ +--TEST-- +Handling of errors during linking +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload_inheritance_error_ind.inc +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +echo "Foobar\n"; +?> +--EXPECT-- +Fatal error: Declaration of B::foo($bar) must be compatible with A::foo() in Unknown on line 0 diff --git a/ext/opcache/tests/preload_inheritance_error.inc b/ext/opcache/tests/preload_inheritance_error.inc new file mode 100644 index 0000000..b0b8274 --- /dev/null +++ b/ext/opcache/tests/preload_inheritance_error.inc @@ -0,0 +1,9 @@ +<?php + +interface A { + public function foo(); +} + +class B implements A { + public function foo($bar) {} +} diff --git a/ext/opcache/tests/preload_inheritance_error_ind.inc b/ext/opcache/tests/preload_inheritance_error_ind.inc new file mode 100644 index 0000000..f8de052 --- /dev/null +++ b/ext/opcache/tests/preload_inheritance_error_ind.inc @@ -0,0 +1,2 @@ +<?php +opcache_compile_file(__DIR__ . '/preload_inheritance_error.inc');

« previous php.cvs (#104671) next »