Don't overwrite unwind exception

When killing a coroutine by throwing an unwind exit into it during
an I/O operation, the I/O failure may result in an exception being
thrown, which will replace the unwind exit exception and the
coroutine will ultimately not exit. This patch avoids this by
ignoring the newly thrown exception and keeping the unwind exit
exception.

Closes GH-7459.
This commit is contained in:
Nikita Popov 2021-09-03 14:30:09 +02:00
parent c87f405084
commit 85b80c5aaf

View File

@ -165,6 +165,12 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
if (exception != NULL) {
zend_object *previous = EG(exception);
if (previous && zend_is_unwind_exit(previous)) {
/* Don't replace unwinding exception with different exception. */
OBJ_RELEASE(exception);
return;
}
zend_exception_set_previous(exception, EG(exception));
EG(exception) = exception;
if (previous) {