Fix ContinuationStore desynchronization#8741
Open
tlively wants to merge 2 commits into
Open
Conversation
When a primary module execution traps or suspends to the host, its continuation store is cleared. Previously, this was done by reassigning the shared_ptr to a new ContinuationStore instance. However, secondary (linked) modules that were instantiated prior to this still hold the original shared_ptr to the old ContinuationStore. This led to desynchronization, where the secondary module would run with stale continuation state (including leaked continuations and resuming flags), eventually causing crashes like assertion failures in visitSuspend. This fix changes clearContinuationStore to clear the ContinuationStore in-place (clearing the continuations vector and resetting resuming flag) instead of reassigning the shared_ptr, ensuring all linked modules continue to share the same cleared state. Added a lit test to verify the fix and prevent regression.
kripken
reviewed
May 21, 2026
| #endif | ||
| continuationStore = std::make_shared<ContinuationStore>(); | ||
| continuationStore->continuations.clear(); | ||
| continuationStore->resuming = false; |
Member
There was a problem hiding this comment.
Please put this in a clear() method on the class, and add a comment here why we call clear to clear it in-place as opposed to wiping it from orbit.
Member
There was a problem hiding this comment.
(putting in the class makes it less likely we forget to add something to clear() if we add something to the class)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a primary module execution traps or suspends to the host, its
continuation store is cleared. Previously, this was done by reassigning
the shared_ptr to a new ContinuationStore instance. However, secondary
(linked) modules that were instantiated prior to this still hold the
original shared_ptr to the old ContinuationStore. This led to
desynchronization, where the secondary module would run with stale
continuation state (including leaked continuations and resuming flags),
eventually causing crashes like assertion failures in visitSuspend.
This fix changes clearContinuationStore to clear the ContinuationStore
in-place (clearing the continuations vector and resetting resuming flag)
instead of reassigning the shared_ptr, ensuring all linked modules
continue to share the same cleared state.
Added a lit test to verify the fix and prevent regression.