[cDAC] Return no debug info for ReadyToRun images without a DebugInfo section - #135059
Merged
Merged
Conversation
… section Match native ReadyToRunInfo::GetDebugInfo, which returns NULL when m_pSectionDebugInfo is null. Images published with --strip-debug-info (now the default for Browser/WASI R2R) have no DebugInfo section; cDAC dereferenced the null ImageDataDirectory and, on wasm where address 0 is readable, decoded garbage and threw BadImageFormatException. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 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
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
steveisok
approved these changes
Oct 1, 2026
lewing
enabled auto-merge (squash)
October 1, 2026 21:57
max-charlamb
approved these changes
Oct 1, 2026
Member
Author
|
/ba-g failures are known |
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.
Native
ReadyToRunInfo::GetDebugInfo(src/coreclr/vm/readytoruninfo.cpp) returnsNULLimmediately whenm_pSectionDebugInfo == NULL. The cDAC mirror,ReadyToRunJitManager.GetDebugInfo, dereferencedReadyToRunInfo.DebugInfoSectionwithout that check and built aNativeArrayfrom whatever was at address 0.This now matters because #134690 makes Browser/WASI ReadyToRun publishes pass
--strip-debug-infoby default, including CoreLib and the framework. iOS, tvOS, and MacCatalyst already default to it. On wasm, linear address 0 is readable, so cDAC decoded garbage. A live run against a stripped browser image threwBadImageFormatException: offset out of bounds(NativeReader.DecodeUnsigned←NativeArray..ctor←ReadyToRunJitManager.GetDebugInfo←DebugInfo_1.GetMethodVarInfo) instead of reporting that there was no debug info. On native targets, the same path fails with a read exception.Changes
ReadyToRunJitManager.GetDebugInforeturnsTargetPointer.Null(withhasFlagByte = false) whenDebugInfoSectionis null, matching native.docs/design/datacontracts/ExecutionManager.md: the R2RGetDebugInfodescription now includes the null-section early return.DebugInfo_1.HasDebugInfo,GetMethodNativeMap,GetMethodVarInfo, andGetAsyncSuspensionPointsalready treat a null debug-info pointer as "no debug info". The two map/var methods still computecodeOffset.Tests
New test
ExecutionManagerTests.GetDebugInfo_R2R_NoDebugInfoSection_ReturnsNullruns as a[Theory]overStdArchAllVersions(4 arch cases). It builds an R2R module whoseDebugInfoSectionis null and makes the low 4 KB of the address space readable as zeros, the way wasm linear memory is, so the unfixed code decodes instead of hitting a read fault. It asserts that:IExecutionManager.GetDebugInforeturnsTargetPointer.NullandhasFlagByte == falseIDebugInfo.HasDebugInfoisfalseGetMethodVarInfoandGetMethodNativeMapreturn empty sequences withcodeOffset == 4Results:
./build.sh -s tools.cdactests -test: passed. UnitTests 3236/3236, DataGeneratorTests 46/46, UsageTests 4/4 (no stale generated docs)../.dotnet/dotnet test src/native/managed/cdac/tests/UnitTests --filter "FullyQualifiedName~GetDebugInfo_R2R_NoDebugInfoSection": passed, 4/4.System.BadImageFormatException : offset out of boundsatNativeReader.DecodeUnsigned←NativeArray..ctor←ReadyToRunJitManager.GetDebugInfo, the same failure as the live wasm run. With the fix restored, it passes 4/4.This PR has a single concern. It leaves wasm stack-walk and variable-location work to #133890, #135044, and #135055.
Note
This PR description was generated with GitHub Copilot.