File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test destructor throwing with unfinished fiber
3
+ --FILE--
4
+ <?php
5
+
6
+ new class () {
7
+ function __destruct () {
8
+ $ fiber = new Fiber (static function () {
9
+ Fiber::suspend ();
10
+ });
11
+ $ fiber ->start ();
12
+ throw new Exception ;
13
+ }
14
+ };
15
+
16
+ --EXPECTF --
17
+ Fatal error: Uncaught Exception in %sthrow-from-destruct-with-fiber.php:%d
18
+ Stack trace:
19
+ #0 %sthrow-from-destruct-with-fiber.php(%d): class@anonymous->__destruct()
20
+ #1 {main}
21
+ thrown in %sthrow-from-destruct-with-fiber.php on line %d
Original file line number Diff line number Diff line change @@ -416,8 +416,11 @@ static void zend_fiber_object_destroy(zend_object *object) /* {{{ */
416
416
zval_ptr_dtor (& fiber -> fci .function_name );
417
417
} else {
418
418
if (fiber -> status == ZEND_FIBER_STATUS_SUSPENDED ) {
419
+ zend_object * exception = EG (exception );
420
+ EG (exception ) = NULL ;
419
421
fiber -> status = ZEND_FIBER_STATUS_SHUTDOWN ;
420
422
zend_fiber_switch_to (fiber );
423
+ EG (exception ) = exception ;
421
424
}
422
425
423
426
zval_ptr_dtor (& fiber -> value );
@@ -434,6 +437,8 @@ static void zend_fiber_object_destroy(zend_object *object) /* {{{ */
434
437
void zend_fiber_cleanup (void ) /* {{{ */
435
438
{
436
439
zend_fiber * fiber ;
440
+ zend_object * exception = EG (exception );
441
+ EG (exception ) = NULL ;
437
442
438
443
ZEND_HASH_REVERSE_FOREACH_PTR (& EG (fibers ), fiber ) {
439
444
if (fiber -> status == ZEND_FIBER_STATUS_SUSPENDED ) {
@@ -442,6 +447,8 @@ void zend_fiber_cleanup(void) /* {{{ */
442
447
zend_fiber_switch_to (fiber );
443
448
}
444
449
} ZEND_HASH_FOREACH_END ();
450
+
451
+ EG (exception ) = exception ;
445
452
}
446
453
/* }}} */
447
454
You can’t perform that action at this time.
0 commit comments