com php-src: Fix preload auto globals handling: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 05.phpt
ext/opcache/tests/preload_globals.inc

From: Date: Fri, 15 Feb 2019 15:37:12 +0000
Subject: com php-src: Fix preload auto globals handling: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 05.phpt
ext/opcache/tests/preload_globals.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104668@lists.php.net to get a copy of this message
Commit: a9497cecf3a76b3264ed0807023cd59e9bcf6f23 Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 16:34:32 +0100 Parents: 0520eb8772280be6469200e37f6e3f25a9c4ff96 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a9497cecf3a76b3264ed0807023cd59e9bcf6f23 Log: Fix preload auto globals handling We need to compute the auto globals mask before EG(symbol_table) is cleaned out. Changed paths: M ext/opcache/ZendAccelerator.c A ext/opcache/tests/preload_005.phpt A ext/opcache/tests/preload_globals.inc Diff: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 985c66c..f30b675 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3837,8 +3837,15 @@ static int accel_preload(const char *config) if (ret == SUCCESS) { zend_persistent_script *script; zend_string *filename; + int ping_auto_globals_mask; int i; + if (PG(auto_globals_jit)) { + ping_auto_globals_mask = zend_accel_get_auto_globals(); + } else { + ping_auto_globals_mask = zend_accel_get_auto_globals_no_jit(); + } + /* Release stored values to avoid dangling pointers */ zend_hash_graceful_reverse_destroy(&EG(symbol_table)); zend_hash_init(&EG(symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); @@ -3859,14 +3866,7 @@ static int accel_preload(const char *config) } script = create_persistent_script(); - - /* Fill in the ping_auto_globals_mask for the new script. If jit for auto globals is enabled we - will have to ping the used auto global variables before execution */ - if (PG(auto_globals_jit)) { - script->ping_auto_globals_mask = zend_accel_get_auto_globals(); - } else { - script->ping_auto_globals_mask = zend_accel_get_auto_globals_no_jit(); - } + script->ping_auto_globals_mask = ping_auto_globals_mask; /* Store all functions and classes in a single pseudo-file */ filename = zend_string_init("$PRELOAD$", strlen("$PRELOAD$"), 0); diff --git a/ext/opcache/tests/preload_005.phpt b/ext/opcache/tests/preload_005.phpt new file mode 100644 index 0000000..1bcfae4 --- /dev/null +++ b/ext/opcache/tests/preload_005.phpt @@ -0,0 +1,16 @@ +--TEST-- +Handling of auto globals during preloading +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload_globals.inc +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$x = 123; +var_dump(get_x()); +?> +--EXPECT-- +int(123) diff --git a/ext/opcache/tests/preload_globals.inc b/ext/opcache/tests/preload_globals.inc new file mode 100644 index 0000000..213dc60 --- /dev/null +++ b/ext/opcache/tests/preload_globals.inc @@ -0,0 +1,5 @@ +<?php + +function get_x() { + return $GLOBALS["x"]; +}

« previous php.cvs (#104668) next »