From 95016138a54b3352a0988878cd71c2ebe7cdeca5 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 13 Feb 2023 16:30:21 +0000 Subject: [PATCH] Fix GH-10496: Fibers must not be garbage collected while implicitly suspended by resumption of another fiber --- .../fibers/{gh10496.phpt => gh10496-001.phpt} | 2 +- Zend/tests/fibers/gh10496-002.phpt | 26 +++++++++++++++++++ Zend/zend_fibers.c | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) rename Zend/tests/fibers/{gh10496.phpt => gh10496-001.phpt} (83%) create mode 100644 Zend/tests/fibers/gh10496-002.phpt diff --git a/Zend/tests/fibers/gh10496.phpt b/Zend/tests/fibers/gh10496-001.phpt similarity index 83% rename from Zend/tests/fibers/gh10496.phpt rename to Zend/tests/fibers/gh10496-001.phpt index 76ea5fea78c..9ca371fa2a6 100644 --- a/Zend/tests/fibers/gh10496.phpt +++ b/Zend/tests/fibers/gh10496-001.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug GH-10496 (Segfault when garbage collector is invoked inside of fiber) +Bug GH-10496 001 (Segfault when garbage collector is invoked inside of fiber) --FILE-- start(); + })(); + })(); +}); +$f->start(); +$f->resume(); + +?> +--EXPECT-- +Success diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c index a0892effdf2..59aa63ba21b 100644 --- a/Zend/zend_fibers.c +++ b/Zend/zend_fibers.c @@ -644,7 +644,7 @@ static HashTable *zend_fiber_object_gc(zend_object *object, zval **table, int *n zend_get_gc_buffer_add_zval(buf, &fiber->fci.function_name); zend_get_gc_buffer_add_zval(buf, &fiber->result); - if (fiber->context.status != ZEND_FIBER_STATUS_SUSPENDED) { + if (fiber->context.status != ZEND_FIBER_STATUS_SUSPENDED || fiber->caller != NULL) { zend_get_gc_buffer_use(buf, table, num); return NULL; }