Repository navigation
Make async GC lifetime assertions deterministic - #392
Merged
Merged
Conversation
Task completion can wake a blocking consumer while the dispatched async callback still holds its state machine and captured payload. A controlled .NET 8/10 reproduction confirms that Lua frames and stack are already empty, and releasing the callback makes the payload collectible. Use a one-shot manual suspension in exception and VM-context lifetime tests so the resumed continuation returns before collection. Preserve actual async suspension and immediate weak-reference assertions, and remove the VM-context test's polling assertion. Production code is unchanged. Validation: 42 focused cases and all 2,585 runtime tests pass on each of .NET 8 and .NET 10 in Release. CSharpier and git diff --check pass.
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.
The GC lifetime assertions could run after task completion but before the completing callback had unwound. That callback could still root its async state machine and captured payload even though Lua had already cleared its stack and frames.
Use a one-shot manual suspension in the exception and VM-context lifetime tests. It preserves genuine async suspension and returns from the resumed continuation before collecting. Remove the VM-context test's polling assertion. Production code is unchanged.
Validation:
git diff --checkpass.No sleeps or retries are used by the updated tests.