Repository navigation
Fix rewriting of configured async enumeration and disposal - #527
Open
Frank Shearar (frankshearar) wants to merge 3 commits into
Open
Frank Shearar (frankshearar) wants to merge 3 commits into
Frank Shearar (frankshearar) wants to merge 3 commits into
Conversation
Rewrite configured async-enumeration producers alongside their ValueTask consumers to avoid incompatible awaitable layouts. Cover cancellation, cleanup, context configuration, and failure replay. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3447f3e5-9328-4334-8f18-0223764709a5
6 tasks
Keep instance allocation when generic constructor arguments are rewritten, while retaining call for static factory replacements. Add class, struct, delegate, and factory regression coverage and update the inspected rewriting IL baseline. Fixes microsoft#528 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3447f3e5-9328-4334-8f18-0223764709a5
…verage Merge the prerequisite from microsoft#529 without rewriting branch history. Cover configured enumerable, nested enumerator, disposable, generic delegate, and custom delegate construction, and update the inspected BugFinding IL baseline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3447f3e5-9328-4334-8f18-0223764709a5
This branch has not been deployed
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.
Summary
Depends on #529 (fixes #528). The prerequisite is merged into this branch without
rewriting its published history; the standalone constructor correction and its
general regression tests remain reviewable in #529.
Fix a process-crashing rewrite of configured async enumeration on .NET 8, including
await foreach (var item in source.WithCancellation(token))andsource.ConfigureAwait(...). Also handle configured async disposal, which sharesthe same configured-ValueTask producer boundary.
The rewriter already replaces
ConfiguredValueTaskAwaitableand its awaiters,but did not replace the framework's configured enumerable, enumerator, or
disposable. Their methods therefore produced native structs for consumers
rewritten to expect Coyote's different struct layout. A minimal configured
async-iterator test aborts the test host with
AccessViolationExceptiononunmodified
main.Changes
TaskAsyncEnumerableExtensions,ConfiguredCancelableAsyncEnumerable<T>,its nested enumerator, and
ConfiguredAsyncDisposableto Coyote wrappers.MoveNextAsyncandDisposeAsyncthrough the existing controllableconfigured-ValueTask awaitables.
existing awaiter behavior continues to force context capture during controlled
testing.
disposal, both context-capture settings, cancellation, chained configuration,
early-exit cleanup, failure replay, configured values in generic constructors
(including the nested enumerator), and generic/custom configuration delegates.
NET, leaving thenetstandard2.0build unchanged.This does not address
CancellationTokenSource.CancelAsyncinterception or TPLDataflow scheduling support.
Validation
Before the fix,
ConfiguredAsyncEnumerableTests.TestWithCancellationaborts thetest host with
System.AccessViolationException.After the fix:
The 18 configured cases pass with the constructor correction. Without it, four
of the added integration cases fail with
InvalidProgramException: enumerable,nested enumerator, disposable, and generic delegate construction. The custom
delegate control passes both versions.
The Windows CI failure on the original head was an outdated IL-diff baseline,
separate from the constructor runtime defect. Updated the inspected BugFinding
baseline to
39A1E35D...: after excluding the new configured test types and theirgenerated state machines, the normalized IL diff matches upstream exactly. The
four before/after integration IL changes are solely
call .ctortonewobj .ctor. The rewriting baseline is inherited from #529.Built the complete solution for
net8.0and ran.\Tests\compare-rewriting-diff-logs.ps1; all five hashes match.Validated on Windows with .NET 8.0.32. Builds emitted
NU1900warnings becauseNuGet vulnerability metadata could not be reached; no compiler/analyzer warnings
were reported.