Skip to content

Commit 8828625

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix symtable cache being used while cleaning symtable
2 parents c702202 + 7b7d998 commit 8828625

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
@@ -3396,12 +3396,13 @@ ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_val
33963396

33973397
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
33983398
{
3399+
/* Clean before putting into the cache, since clean could call dtors,
3400+
* which could use the cached hash. Also do this before the check for
3401+
* available cache slots, as those may be used by a dtor as well. */
3402+
zend_symtable_clean(symbol_table);
33993403
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
34003404
zend_array_destroy(symbol_table);
34013405
} else {
3402-
/* clean before putting into the cache, since clean
3403-
could call dtors, which could use cached hash */
3404-
zend_symtable_clean(symbol_table);
34053406
*(EG(symtable_cache_ptr)++) = symbol_table;
34063407
}
34073408
}

0 commit comments

Comments
 (0)