File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -269,20 +269,21 @@ ZEND_API zend_fiber_context *zend_fiber_switch_context(zend_fiber_context *to)
269
269
270
270
EG (current_fiber ) = from ;
271
271
272
- zend_fiber_restore_vm_state (& state );
273
-
274
272
zend_fiber_context * previous = transfer .data ;
275
273
previous -> handle = transfer .context ;
276
274
277
- if (UNEXPECTED (previous -> flags & ZEND_FIBER_FLAG_BAILOUT )) {
278
- // zend_bailout() was called in the fiber, so call it again in the previous fiber or {main}.
279
- zend_bailout ();
280
- }
275
+ zend_fiber_restore_vm_state (& state );
281
276
277
+ /* Destroy context first to ensure it does not leak if some extension does custom bailout handling. */
282
278
if (previous -> status == ZEND_FIBER_STATUS_DEAD ) {
283
279
zend_fiber_destroy_context (previous );
284
280
}
285
281
282
+ /* Propagate bailout to current fiber / main. */
283
+ if (UNEXPECTED (previous -> flags & ZEND_FIBER_FLAG_BAILOUT )) {
284
+ zend_bailout ();
285
+ }
286
+
286
287
return previous ;
287
288
}
288
289
@@ -492,7 +493,7 @@ ZEND_METHOD(Fiber, suspend)
492
493
fiber -> execute_data = EG (current_execute_data );
493
494
fiber -> stack_bottom -> prev_execute_data = NULL ;
494
495
495
- zend_fiber_switch_context (zend_fiber_get_context ( fiber ) -> caller );
496
+ zend_fiber_switch_context (fiber -> caller );
496
497
497
498
if (fiber -> flags & ZEND_FIBER_FLAG_DESTROYED ) {
498
499
// This occurs when the fiber is GC'ed while suspended.
You can’t perform that action at this time.
0 commit comments