Check if fiber was destroyed before resuming #84
Merged
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.
Since fixing the hard reference retained to suspensions in the event loop, the cycle collector may collect an object holding a
DriverSuspension, theDriverSuspensionitself, and the suspendedFiber, queuing them for destruction. Once queued for destruction, all destructors are invoked. If the object holding the suspension queues the fiber to be resumed, the fiber destructor is run and the fiber terminated before it can be resumed.This PR adds a check if the fiber has been destroyed while the fiber was queued to be resumed. I believe the fiber can only be destroyed while being queued for resuming after a call to
gc_collect_cyclesor if the cycle collector is automatically triggered.The only alternative seems to be to retain a hard reference to the fiber elsewhere, but this would again cause any non-resumed fiber to leak because the fiber reference would remain in the list of hard references.