Skip to content

Commit 3f4a151

Browse files
committed
Handle reallocated root buffer during GC destroy phase
We no longer protect GC during the destroy phase, so we need to deal with buffer reallocation. Possible fix for bug #78811.
1 parent 51ac4e3 commit 3f4a151

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Zend/zend_gc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,11 +1547,11 @@ ZEND_API int zend_gc_collect_cycles(void)
15471547
}
15481548
}
15491549

1550-
/* Destroy zvals */
1550+
/* Destroy zvals. The root buffer may be reallocated. */
15511551
GC_TRACE("Destroying zvals");
1552-
current = GC_IDX2PTR(GC_FIRST_ROOT);
1553-
last = GC_IDX2PTR(GC_G(first_unused));
1554-
while (current != last) {
1552+
idx = GC_FIRST_ROOT;
1553+
while (idx != end) {
1554+
current = GC_IDX2PTR(idx);
15551555
if (GC_IS_GARBAGE(current->ref)) {
15561556
p = GC_GET_PTR(current->ref);
15571557
GC_TRACE_REF(p, "destroying");
@@ -1582,11 +1582,12 @@ ZEND_API int zend_gc_collect_cycles(void)
15821582
zend_hash_destroy(arr);
15831583
}
15841584
}
1585-
current++;
1585+
idx++;
15861586
}
15871587

15881588
/* Free objects */
15891589
current = GC_IDX2PTR(GC_FIRST_ROOT);
1590+
last = GC_IDX2PTR(end);
15901591
while (current != last) {
15911592
if (GC_IS_GARBAGE(current->ref)) {
15921593
p = GC_GET_PTR(current->ref);

0 commit comments

Comments
 (0)