Harden async-profiler dispatcher/wrapper frame name contract for callstack stitching. - #131963
Merged
lateralusX merged 1 commit intoAug 7, 2026
Conversation
continuation-wrapper frames by method/type name and expects them to be consistently filtered from managed stack traces. Nothing in the runtime guarded that implicit contract, so a rename, an added/removed continuation wrapper, or a lost [StackTraceHidden] marker could silently break async callstack stitching for both StateMachineAsync (V1) and RuntimeAsync (V2). Runtime (System.Private.CoreLib): - Mark the V1 state-machine dispatch frames [StackTraceHidden] (InstrumentedMoveNext, MoveNextAsDispatcher, AsyncStateMachineDispatcher.MoveNext) to match the V2 RuntimeAsync dispatch frames, so they are consistently hidden from managed stack traces while remaining resolvable by name from stack-trace metadata. - Add diagnostic-tooling name-contract comments (unified below the attribute) on the dispatcher/wrapper methods the stitcher recognizes by name. - Rename the (unshipped) env var DOTNET_AsyncProfilerEventSource_EventBufferSize to DOTNET_AsyncProfiler_EventBufferSize for naming consistency; drop a now-unused using. Tests (System.Threading.Tasks.Tests): - Name-contract tests pinning the exact names/count the stitcher hardcodes: V1/V2 dispatch methods and the 32 V2 continuation-wrapper methods (asserting all 32 exist and none beyond). - Frame-capture tests that capture the UNFILTERED physical managed stack from inside a resumed continuation and assert the boundary frames appear in the expected leaf->root order: V2 single-yield, V1 single-yield, V1 pooling, and V1 inline-completion climb. Frame identity is resolved via DiagnosticMethodInfo so the tests work on CoreCLR, Mono, and NativeAOT (where reflection metadata is trimmed but stack-trace metadata is not).
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices |
Member
Author
|
/ba-g known issue #131956 |
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.
Changes
Runtime (
System.Private.CoreLib)[StackTraceHidden]to the V1 dispatch frames (InstrumentedMoveNext,MoveNextAsDispatcher,AsyncStateMachineDispatcher.MoveNext) so V1 matches the already-hidden V2 dispatch frames. These frames stay out of managed stack traces but remain in the physical stack and in stack-trace metadata.DOTNET_AsyncProfilerEventSource_EventBufferSize→DOTNET_AsyncProfiler_EventBufferSize; remove an unusedusing.Tests (
System.Threading.Tasks.Tests)RuntimeAsync_ResumeDispatchStack(V2 single-yield)StateMachineAsync_ResumeDispatchStack(V1 single-yield)StateMachineAsync_PoolingResumeDispatchStack(V1 pooling → standaloneAsyncStateMachineDispatcher)StateMachineAsync_InlineCompletionClimb(V1 inline completion, child frames remain beneath the resuming parent)DiagnosticMethodInfo(stack-trace metadata) rather thanStackFrame.GetMethod()(reflection), so the tests work on CoreCLR, Mono, and NativeAOT — the latter trims reflection metadata but preserves stack-trace metadata (including names for[StackTraceHidden]Ecma methods).Tests are gated by runtime capability: V1 tests run on CoreCLR + Mono; V2 tests run on CoreCLR (+ NativeAOT for the frame-capture test); reflection-based name-contract tests are CoreCLR/Mono only.
Risk / compatibility
[StackTraceHidden]only affects stack-trace display, and the newly-hidden V1InstrumentedMoveNextframes are only present when the async profiler is active.