Skip to content

Zend: zend_fiber_execute() discards exit() in a destroyed fiber. - #24285

Closed
devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh24265
Closed

devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh24265

Conversation

@devnexen

Copy link
Copy Markdown
Member

Fix #24265

A destroyed fiber swallowed UnwindExit along with the GracefulExit used to unwind it, so exit() in a finally block or destructor was lost. Only the GracefulExit is swallowed now.

@devnexen devnexen linked an issue Oct 13, 2026 that may be closed by this pull request
@devnexen
devnexen marked this pull request as ready for review October 13, 2026 01:48
Comment thread Zend/zend_fibers.c Outdated
Comment on lines +798 to +802
if (exception && zend_is_unwind_exit(EG(exception))) {
OBJ_RELEASE(exception);
} else {
zend_exception_set_previous(EG(exception), exception);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (exception && zend_is_unwind_exit(EG(exception))) {
OBJ_RELEASE(exception);
} else {
zend_exception_set_previous(EG(exception), exception);
}
zend_exception_set_previous(EG(exception), exception);

This should work, no ? zend_exception_set_previous already handled an unwind exit the same way. Or am I missing something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My changes predated the set_previous change from the bailout fix. Now your suggestion works :)

Fix php#24265

A destroyed fiber swallowed UnwindExit along with the GracefulExit used
to unwind it, so exit() in a finally block or destructor was lost. Only
the GracefulExit is swallowed now.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@devnexen devnexen closed this in afd1569 Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unwind/GracefulExit discarded in zend_fiber_execute()

2 participants