Skip to content

Commit 8821279

Browse files
committed
Fix coroutine garbage collection: Prevent double ZVAL_DELREF by skipping duplicate symbol tables
1 parent eae4bab commit 8821279

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

coroutine.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,18 @@ static HashTable *async_coroutine_object_gc(zend_object *object, zval **table, i
308308
symTable = zend_unfinished_execution_gc_ex(
309309
ex, ex->func && ZEND_USER_CODE(ex->func->type) ? ex->call : NULL, buf, false);
310310
}
311+
311312
if (symTable) {
313+
/*
314+
* Skip if this is the same symbol_table as previous frame (include shares symbol_table)
315+
* Include operators inherit the symbol_table,
316+
* which causes the same zval to be registered twice in the garbage collector.
317+
* This leads to a double ZVAL_DELREF attempt.
318+
*/
319+
if (lastSymTable && lastSymTable == symTable) {
320+
continue;
321+
}
322+
312323
if (lastSymTable) {
313324
zval *val;
314325
ZEND_HASH_FOREACH_VAL(lastSymTable, val)

0 commit comments

Comments
 (0)