Skip to content

Commit 87ddddc

Browse files
committed
Fix GH-10437: Set active fiber to null on bailout
1 parent a8c8fb2 commit 87ddddc

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed incorrect check condition in ZEND_YIELD. (nielsdos)
77
. Fixed incorrect check condition in type inference. (nielsdos)
8+
. Fixed bug GH-10437 (Segfault/assertion when using fibers in shutdown
9+
function after bailout). (trowski)
810

911
- FFI:
1012
. Fixed incorrect bitshifting and masking in ffi bitfield. (nielsdos)

Zend/tests/fibers/gh10437.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10437 (Segfault/assertion when using fibers in shutdown function after bailout)
3+
--FILE--
4+
<?php
5+
6+
register_shutdown_function(function (): void {
7+
var_dump(Fiber::getCurrent());
8+
});
9+
10+
$fiber = new Fiber(function (): never {
11+
trigger_error('Bailout in fiber', E_USER_ERROR);
12+
});
13+
$fiber->start();
14+
15+
?>
16+
--EXPECTF--
17+
Fatal error: Bailout in fiber in %sgh10437.php on line %d
18+
NULL

Zend/zend_fibers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ static zend_always_inline zend_fiber_transfer zend_fiber_switch_to(
543543

544544
/* Forward bailout into current fiber. */
545545
if (UNEXPECTED(transfer.flags & ZEND_FIBER_TRANSFER_FLAG_BAILOUT)) {
546+
EG(active_fiber) = NULL;
546547
zend_bailout();
547548
}
548549

0 commit comments

Comments
 (0)