mirror of
https://github.com/php/php-src.git
synced 2025-01-25 05:04:20 +08:00
Fix preload auto globals handling
We need to compute the auto globals mask before EG(symbol_table) is cleaned out.
This commit is contained in:
parent
0520eb8772
commit
a9497cecf3
@ -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);
|
||||
|
16
ext/opcache/tests/preload_005.phpt
Normal file
16
ext/opcache/tests/preload_005.phpt
Normal file
@ -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)
|
5
ext/opcache/tests/preload_globals.inc
Normal file
5
ext/opcache/tests/preload_globals.inc
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
function get_x() {
|
||||
return $GLOBALS["x"];
|
||||
}
|
Loading…
Reference in New Issue
Block a user