Fix #3754: omit async stepping info for runtime-async methods - #3832
Merged
Conversation
siegfriedpammer
commented
Jun 27, 2026
siegfriedpammer
commented
Jun 27, 2026
siegfriedpammer
force-pushed
the
fix-3754-runtime-async-pdb
branch
from
June 27, 2026 11:53
964edba to
517446c
Compare
ILFunction.IsAsync is derived from the method signature, so .NET 11 runtime-async methods (MethodImplAsync bit, no MoveNext state machine) report IsAsync without AsyncAwaitDecompiler ever populating AsyncDebugInfo. Its Awaits then stays an uninitialized ImmutableArray, and PortablePdbWriter threw an NRE building the MethodSteppingInformation blob from that default struct. Runtime-async methods have no yield/resume offsets to record, so guard on Awaits.IsDefault and omit the blob, matching the C# compiler, which emits no stepping information for them either. A genuinely zero-await classic state machine keeps an initialized empty Awaits and is unaffected. Assisted-by: Claude:claude-opus-4-8:Claude Code
siegfriedpammer
force-pushed
the
fix-3754-runtime-async-pdb
branch
from
June 27, 2026 16:06
517446c to
1bdb3c2
Compare
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.
Fixes #3754.
Problem
Generating a portable PDB for an assembly containing .NET 11 runtime-async methods threw a
NullReferenceExceptioninstead of producing a PDB:Root cause
ILFunction.IsAsyncis derived from the method signature, so runtime-async methods (MethodImplAsyncbit, no MoveNext state machine) reportIsAsyncwithoutAsyncAwaitDecompilerever populatingAsyncDebugInfo. ItsAwaitsthen stays an uninitializedImmutableArray<Await>, andPortablePdbWriterthrew building theMethodSteppingInformationblob from that default struct.Fix
Guard emission with
!function.AsyncDebugInfo.Awaits.IsDefault. Runtime-async methods have no yield/resume offsets to record, so the stepping blob is omitted, matching the C# compiler (which emits no stepping information for them either). A genuinely zero-await classic state machine keeps an initialized emptyAwaitsand is unaffected (IsDefault, notIsDefaultOrEmpty).Test
Adds a
PdbGen/RuntimeAsync.csfixture and aPdbGenerationTestRunner.RuntimeAsynctest that compiles a runtime-async method in-proc (newruntimeAsyncflag onTester.CompileCSharpWithPdb, mirroring the out-of-process/features:runtime-async=on), runsPortablePdbWriter, and asserts it does not throw and emits noMethodSteppingInformation. The test fails with the NRE before the fix and passes after; the full PdbGen fixture stays green.Verified end-to-end with
ilspycmd -genpdbon a minimal runtime-async assembly (valid PDB, no stepping info) and on the issue'sSystem.Net.Requests.dll(past the NRE).🤖 Generated with Claude Code