-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Handle BadImageFormatException in OpenAssociatedSymbolFile #124228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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