[Java.Interop.Tools.Cecil] Fix retry logic in ReadAssembly to skip symbol loading#1401
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes DirectoryAssemblyResolver.ReadAssembly() retry behavior in Java.Interop.Tools.Cecil so that when the initial read fails due to locked PDB/symbol loading, the retry actually skips symbol loading instead of re-attempting the same failing path (addressing build failures like XA0009/XAPTP7000 reported in dotnet/android#11081).
Changes:
- Thread a new
bool loadSymbolsparameter throughLoadFromMemoryMappedFile()to explicitly control whether symbols are loaded. - Update the retry path in
ReadAssembly()to callLoadFromMemoryMappedFile(..., loadSymbols: false)after a failure when loading with symbols.
src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs
Show resolved
Hide resolved
src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs
Show resolved
Hide resolved
366a73b to
c23b860
Compare
jonathanpeppers
left a comment
There was a problem hiding this comment.
🤖 AI Review Summary
Verdict: ✅ LGTM (pending CI)
Found 0 issues, 1 suggestion:
- 💡 Testing: Consider adding a regression test for the locked-PDB retry path (DirectoryAssemblyResolverTests.cs)
Analysis
The bug is real and well-explained: LoadFromMemoryMappedFile checked the instance field loadDebugSymbols instead of respecting the caller's intent, so the retry path in ReadAssembly re-opened the same locked PDB and threw the same IOException.
The fix correctly threads a bool loadSymbols parameter through LoadFromMemoryMappedFile so the retry can pass false to actually skip symbol loading. The if (!loadDebugSymbols) throw; guard is a nice defensive addition — if we're not loading symbols in the first place, there's nothing to retry.
👍 Clean, minimal fix that addresses root cause rather than symptoms. Good PR description with clear problem/fix separation.
dotnet.java-interop pipeline is still queued. LGTM is conditional on CI passing.
Review generated by android-reviewer from review guidelines.
src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs
Show resolved
Hide resolved
…mbol loading The retry in ReadAssembly sets reader_parameters.ReadSymbols = false, but LoadFromMemoryMappedFile checks the instance field loadDebugSymbols instead, so the retry re-opens the same locked PDB file and throws the same IOException. Fix by passing an explicit loadSymbols parameter to LoadFromMemoryMappedFile so the retry can actually skip symbol loading. When loadDebugSymbols is false, rethrow immediately since there is nothing to retry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c23b860 to
8bd8268
Compare
Summary
The retry path in
DirectoryAssemblyResolver.ReadAssemblywas broken - it setreader_parameters.ReadSymbols = falsebutLoadFromMemoryMappedFilechecked the instance fieldloadDebugSymbolsinstead, so the retry would re-open the same locked PDB file and throw the sameIOException.Problem
When a PDB file in the NuGet cache is locked by another process (e.g. the .NET SDK trimmer running concurrently),
LoadSymbolsthrows anIOException. TheReadAssemblymethod has a catch block that is supposed to retry without symbols, but the retry callsLoadFromMemoryMappedFilewhich checksloadDebugSymbols(alwaystrue) and callsLoadSymbolsagain - hitting the same locked file.This causes
error XAPTP7000 / XA0009build failures:Fix
Add an explicit
bool loadSymbolsparameter toLoadFromMemoryMappedFileso the retry can passfalseto actually skip symbol loading.Context: dotnet/android#11081