Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,10 @@ bool async_scheduler_main_coroutine_suspend(const bool with_bailout)
if (EG(exception) != NULL && exit_exception != NULL) {
if (UNEXPECTED(EG(exception) != exit_exception)) {
zend_exception_set_previous(EG(exception), exit_exception);
} else {
// Already the pending exception, so there is nobody to hand the global's reference to.
// The other two branches consume it; this one drops it.
OBJ_RELEASE(exit_exception);
}
} else if (exit_exception != NULL) {
async_rethrow_exception(exit_exception);
Expand Down Expand Up @@ -2050,10 +2054,15 @@ ZEND_STACK_ALIGNED void fiber_entry(zend_fiber_transfer *transfer)
if (UNEXPECTED(EG(exception) != exit_exception)) {
zend_exception_set_previous(EG(exception), exit_exception);
}
exit_exception = EG(exception);
GC_ADDREF(exit_exception);

// ZEND_ASYNC_EXIT_EXCEPTION owns its reference: the new exit exception goes into the global, not
// into the local, otherwise the added reference has no owner.
ZEND_ASYNC_EXIT_EXCEPTION = EG(exception);
GC_ADDREF(EG(exception));
zend_clear_exception();
} else if (exit_exception != NULL) {
// The rethrow moves the global's reference into EG(exception), so the global must let it go.
ZEND_ASYNC_EXIT_EXCEPTION = NULL;
async_rethrow_exception(exit_exception);
}

Expand Down
Loading