@@ -44,6 +44,8 @@ static zend_class_entry *zend_ce_fiber_error;
4444
4545static zend_object_handlers zend_fiber_handlers ;
4646
47+ static zend_function zend_fiber_function = { ZEND_INTERNAL_FUNCTION };
48+
4749typedef void * fcontext_t ;
4850
4951typedef struct _transfer_t {
@@ -331,9 +333,13 @@ static void ZEND_STACK_ALIGNED zend_fiber_execute(zend_fiber_context *context)
331333 EG (vm_stack_page_size ) = ZEND_FIBER_VM_STACK_SIZE ;
332334
333335 fiber -> execute_data = (zend_execute_data * ) stack -> top ;
336+ fiber -> stack_bottom = fiber -> execute_data ;
334337
335338 memset (fiber -> execute_data , 0 , sizeof (zend_execute_data ));
336339
340+ fiber -> execute_data -> func = & zend_fiber_function ;
341+ fiber -> stack_bottom -> prev_execute_data = EG (current_execute_data );
342+
337343 EG (current_execute_data ) = fiber -> execute_data ;
338344 EG (jit_trace_num ) = 0 ;
339345 EG (error_reporting ) = error_reporting ;
@@ -360,6 +366,7 @@ static void ZEND_STACK_ALIGNED zend_fiber_execute(zend_fiber_context *context)
360366
361367 zend_vm_stack_destroy ();
362368 fiber -> execute_data = NULL ;
369+ fiber -> stack_bottom = NULL ;
363370}
364371
365372static zend_object * zend_fiber_object_create (zend_class_entry * ce )
@@ -494,6 +501,7 @@ ZEND_METHOD(Fiber, suspend)
494501
495502 fiber -> execute_data = execute_data ;
496503 fiber -> status = ZEND_FIBER_STATUS_SUSPENDED ;
504+ fiber -> stack_bottom -> prev_execute_data = NULL ;
497505
498506 zend_fiber_suspend (fiber );
499507
@@ -547,6 +555,7 @@ ZEND_METHOD(Fiber, resume)
547555 }
548556
549557 fiber -> status = ZEND_FIBER_STATUS_RUNNING ;
558+ fiber -> stack_bottom -> prev_execute_data = execute_data ;
550559
551560 zend_fiber_switch_to (fiber );
552561
@@ -578,6 +587,7 @@ ZEND_METHOD(Fiber, throw)
578587 fiber -> exception = exception ;
579588
580589 fiber -> status = ZEND_FIBER_STATUS_RUNNING ;
590+ fiber -> stack_bottom -> prev_execute_data = execute_data ;
581591
582592 zend_fiber_switch_to (fiber );
583593
0 commit comments