Skip to content

Commit e70f1b0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix symtable cache being used while cleaning symtable
2 parents 643a727 + 8828625 commit e70f1b0

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Symtable cache slots may be acquired while cleaning symtable
3+
--FILE--
4+
<?php
5+
class A {
6+
// Must be larger than the symtable cache.
7+
static $max = 40;
8+
function __destruct() {
9+
if (self::$max-- < 0) return;
10+
$x = 'y';
11+
$$x = new a;
12+
}
13+
}
14+
new A;
15+
16+
?>
17+
===DONE===
18+
--EXPECT--
19+
===DONE===

Zend/zend_execute.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,12 +3412,13 @@ ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_val
34123412

34133413
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
34143414
{
3415+
/* Clean before putting into the cache, since clean could call dtors,
3416+
* which could use the cached hash. Also do this before the check for
3417+
* available cache slots, as those may be used by a dtor as well. */
3418+
zend_symtable_clean(symbol_table);
34153419
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
34163420
zend_array_destroy(symbol_table);
34173421
} else {
3418-
/* clean before putting into the cache, since clean
3419-
could call dtors, which could use cached hash */
3420-
zend_symtable_clean(symbol_table);
34213422
*(EG(symtable_cache_ptr)++) = symbol_table;
34223423
}
34233424
}

0 commit comments

Comments
 (0)