File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Reference to invocable class retained while running
3
+ --FILE--
4
+ <?php
5
+
6
+ class Test {
7
+ public function __invoke () {
8
+ $ GLOBALS ['test ' ] = null ;
9
+ var_dump ($ this );
10
+ try {
11
+ Fiber::suspend ();
12
+ } finally {
13
+ var_dump ($ this );
14
+ }
15
+ }
16
+ }
17
+
18
+ $ test = new Test ;
19
+ $ fiber = new Fiber ($ test );
20
+ $ fiber ->start ();
21
+
22
+ ?>
23
+ --EXPECT--
24
+ object(Test)#1 (0) {
25
+ }
26
+ object(Test)#1 (0) {
27
+ }
Original file line number Diff line number Diff line change @@ -349,6 +349,8 @@ static void ZEND_STACK_ALIGNED zend_fiber_execute(zend_fiber_context *context)
349
349
350
350
zend_call_function (& fiber -> fci , & fiber -> fci_cache );
351
351
352
+ zval_ptr_dtor (& fiber -> fci .function_name );
353
+
352
354
if (EG (exception )) {
353
355
if (fiber -> status == ZEND_FIBER_STATUS_SHUTDOWN ) {
354
356
if (EXPECTED (zend_is_graceful_exit (EG (exception )) || zend_is_unwind_exit (EG (exception )))) {
@@ -390,9 +392,13 @@ static void zend_fiber_object_destroy(zend_object *object)
390
392
if (fiber -> status == ZEND_FIBER_STATUS_SUSPENDED ) {
391
393
zend_object * exception = EG (exception );
392
394
EG (exception ) = NULL ;
395
+
393
396
fiber -> status = ZEND_FIBER_STATUS_SHUTDOWN ;
397
+ // Additional reference needed while running, removed in zend_fiber_execute.
394
398
GC_ADDREF (& fiber -> std );
399
+
395
400
zend_fiber_switch_to (fiber );
401
+
396
402
EG (exception ) = exception ;
397
403
}
398
404
}
@@ -452,8 +458,6 @@ ZEND_METHOD(Fiber, start)
452
458
453
459
zend_fiber_switch_to (fiber );
454
460
455
- zval_ptr_dtor (& fiber -> fci .function_name );
456
-
457
461
if (fiber -> status & ZEND_FIBER_STATUS_FINISHED ) {
458
462
RETURN_NULL ();
459
463
}
You can’t perform that action at this time.
0 commit comments