Fix destruction of suspended generators in suspended fibers during shutdown #15158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #15108.
In #10462 we ensured that generators running in a fiber are not destroyed before the fiber:
This was extended to support
yield from
in 00be6e1 and b9bca2d (I can not find the related PR anymore).Here I fix two additional cases not handled by #10462:
The
ZEND_GENERATOR_IN_FIBER
flag was not added when resuming ayield from $nonGenerator
. I fix that by adding the flag earlier.When a generator that is running in a fiber has multiple children (aka multiple generators yielding from it), all of them could be considered to also run in a fiber (only one actually is), and could leak if not destroyed before shutdown.
Unfortunately the second one requires traversing the child tree (at most once) during dtor if the root is marked
ZEND_GENERATOR_IN_FIBER
.