Set EG(active)=0 during preloading shutdown

Just like during normal shutdown, we should set EG(active)=0
during the partial preloading shutdown, to make sure that no
user code can run.

We need to slightly tweak inheritance class loading to still
pick the right code path.
This commit is contained in:
Nikita Popov 2021-08-16 15:53:12 +02:00
parent 99ddc806dc
commit 4bb66ddc76
2 changed files with 5 additions and 2 deletions

View file

@ -228,8 +228,9 @@ static zend_always_inline void register_unresolved_class(zend_string *name) {
static zend_class_entry *lookup_class_ex(
zend_class_entry *scope, zend_string *name, bool register_unresolved) {
zend_class_entry *ce;
bool in_preload = CG(compiler_options) & ZEND_COMPILE_PRELOAD;
if (UNEXPECTED(!EG(active))) {
if (UNEXPECTED(!EG(active) && !in_preload)) {
zend_string *lc_name = zend_string_tolower(name);
ce = zend_hash_find_ptr(CG(class_table), lc_name);
@ -248,7 +249,7 @@ static zend_class_entry *lookup_class_ex(
ce = zend_lookup_class_ex(
name, NULL, ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (!CG(in_compilation) || (CG(compiler_options) & ZEND_COMPILE_PRELOAD)) {
if (!CG(in_compilation) || in_preload) {
if (ce) {
return ce;
}

View file

@ -4448,6 +4448,8 @@ static int accel_preload(const char *config, bool in_child)
php_output_end_all();
php_free_shutdown_functions();
EG(active) = 0;
/* 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);