File tree 2 files changed +26
-0
lines changed 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Make sure exceptions are rethrown when throwing from fiber destructor
3
+ --FILE--
4
+ <?php
5
+ $ fiber = new Fiber (function () {
6
+ try {
7
+ Fiber::suspend ();
8
+ } finally {
9
+ throw new Exception ("Exception 2 " );
10
+ }
11
+ });
12
+ $ fiber ->start ();
13
+ unset($ fiber );
14
+ throw new Exception ("Exception 1 " );
15
+ ?>
16
+ --EXPECTF--
17
+ Fatal error: Uncaught Exception: Exception 2 in %s:%d
18
+ Stack trace:
19
+ #0 [internal function]: {closure}()
20
+ #1 {main}
21
+ thrown in %s on line %d
Original file line number Diff line number Diff line change @@ -398,6 +398,11 @@ static void zend_fiber_object_destroy(zend_object *object)
398
398
zend_fiber_switch_to (fiber );
399
399
400
400
if (EG (exception )) {
401
+ if (!exception && EG (current_execute_data ) && EG (current_execute_data )-> func
402
+ && ZEND_USER_CODE (EG (current_execute_data )-> func -> common .type )) {
403
+ zend_rethrow_exception (EG (current_execute_data ));
404
+ }
405
+
401
406
zend_exception_set_previous (EG (exception ), exception );
402
407
403
408
if (EG (flags ) & EG_FLAGS_IN_SHUTDOWN ) {
You can’t perform that action at this time.
0 commit comments