Handle BadImageFormatException in OpenAssociatedSymbolFile#124228
Handle BadImageFormatException in OpenAssociatedSymbolFile#124228stephentoub wants to merge 1 commit intodotnet:mainfrom
Conversation
Catch BadImageFormatException from PEReader.ReadCodeViewDebugDirectoryData and skip malformed CodeView entries instead of crashing. This is consistent with how other PDB loading failures are handled in the same method. Fixes https://github.com/dotnet/dotnet/issues/4733
🤖 Copilot Code Review — PR #124228Holistic AssessmentMotivation: The crash is real — issue #124181 shows crossgen2 fatally crashing with Approach: Catching Summary: Detailed Findings✅ Code Correctness — Exception handling is appropriateThe
|
There was a problem hiding this comment.
Pull request overview
Updates symbol/PDB association logic in CoreCLR tooling to tolerate malformed CodeView debug directory entries by skipping them instead of crashing, aligning behavior with other PDB-loading failure handling.
Changes:
- Catch
BadImageFormatExceptionfromPEReader.ReadCodeViewDebugDirectoryDataand continue to the next debug entry. - Apply the same robustness fix in both dotnet-pgo and the common compiler type system context.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/tools/dotnet-pgo/TraceTypeSystemContext.cs | Skips malformed CodeView entries when reading CodeView debug directory data while locating associated PDBs. |
| src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs | Matches the same exception-handling behavior for CodeView debug directory parsing during PDB association. |
| continue; | ||
| } | ||
|
|
||
| string candidatePath = debugDirectoryData.Path; | ||
| if (!Path.IsPathRooted(candidatePath) || !File.Exists(candidatePath)) |
There was a problem hiding this comment.
There’s an extra double-space before the '=' in the candidatePath declaration; please normalize spacing to a single space for consistency/readability.
Catch BadImageFormatException from PEReader.ReadCodeViewDebugDirectoryData and skip malformed CodeView entries instead of crashing. This is consistent with how other PDB loading failures are handled in the same method.
Fixes https://github.com/dotnet/dotnet/issues/4733