Use no-op MD Importer for DIA-backed stacktraces#129866
Open
hoyosjs wants to merge 16 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes CoreCLR’s symbol-reader setup in Module::GetISymUnmanagedReader to avoid materializing a module’s real public metadata importer when constructing DIA-backed symbol readers, by instead passing a process-wide inert IMetaDataImport2 implementation.
Changes:
- Introduces
NoopMetadataImport, a singletonIMetaDataImport2implementation intended only to satisfy the binder’s non-null metadata-import parameter. - Updates
Module::GetISymUnmanagedReaderto pass the noop importer toISymUnmanagedBinder::GetReaderFromStream/GetReaderForFileinstead of using the module’s importer. - Wires the new files into the VM build via
src/coreclr/vm/CMakeLists.txt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/vm/noopmetadataimport.h | Declares NoopMetadataImport singleton implementing IMetaDataImport2 as an inert binder placeholder. |
| src/coreclr/vm/noopmetadataimport.cpp | Implements singleton creation, COM QI/AddRef/Release behavior, and E_NOTIMPL stubs for metadata APIs. |
| src/coreclr/vm/CMakeLists.txt | Adds the new noop importer source/header to VM build lists. |
| src/coreclr/vm/ceeload.cpp | Switches symbol-reader binder calls to use NoopMetadataImport::GetInstance() instead of module metadata importers. |
AaronRobinsonMSFT
approved these changes
Jun 25, 2026
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
AaronRobinsonMSFT
approved these changes
Jun 26, 2026
jkotas
reviewed
Jun 26, 2026
jkotas
reviewed
Jun 26, 2026
jkotas
reviewed
Jun 28, 2026
davidwrighton
approved these changes
Jun 29, 2026
Comment on lines
+8
to
+12
| <!-- DIA isn't used under Native AOT at runtime, but ensure that ILC does create | ||
| line number blobs from full PDB that can be used in runtime stack traces. --> | ||
| <StackTraceLineNumberSupport>true</StackTraceLineNumberSupport> | ||
| <PreservePdbInHelixPayload>true</PreservePdbInHelixPayload> | ||
| </PropertyGroup> |
| <!-- DIA isn't used under Native AOT at runtime, but ensure that ILC does create | ||
| line number blobs from full PDB that can be used in runtime stack traces. --> | ||
| <StackTraceLineNumberSupport>true</StackTraceLineNumberSupport> | ||
| <PreservePdbInHelixPayload>true</PreservePdbInHelixPayload> |
jkotas
reviewed
Jul 2, 2026
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
jkotas
reviewed
Jul 2, 2026
Member
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jkotas
approved these changes
Jul 2, 2026
Comment on lines
18
to
23
| // C++/CLI IJW varargs is Windows-only and unavailable on Nano Server. | ||
| public static bool IsSupported => TestLibrary.Utilities.IsWindows && !TestLibrary.Utilities.IsWindowsNanoServer; | ||
| [ActiveIssue("C++/CLI, IJW not supported on Mono", TestRuntimes.Mono)] | ||
| [Fact] | ||
| [PlatformSpecific(TestPlatforms.Windows)] | ||
| [Fact] | ||
| public static int TestEntryPoint() |
Comment on lines
+329
to
+342
| <!-- Tests opt into keeping their managed pdbs in the Helix payload with PreservePdbInHelixPayload=true, which drops a | ||
| <AssemblyName>.PreservePdb marker beside the pdbs in the per-test output directory. The merged wrapper directory that | ||
| seeds _MergedPayloadFiles is a flattened copy of every test's assemblies and pdbs but omits those marker files, so | ||
| probe the original per-test output tree ($(TestBinDir)) for the markers and collect the names of the pdbs that sit | ||
| next to them. A pdb with one of these names is kept below; because each pdb name only exists in its own merge group's | ||
| flattened payload, this preserves exactly the opted-in pdbs and lands them next to their dll. --> | ||
| <ItemGroup Condition="'@(_MergedPayloadFiles)' != ''"> | ||
| <_PreservePdbMarkers Include="$(TestBinDir)**\*.PreservePdb" /> | ||
| <_PreservePdbMarkerDirectories Include="@(_PreservePdbMarkers->'%(RootDir)%(Directory)')" KeepDuplicates="false" /> | ||
| <_PreservePdbSourceFiles Include="%(_PreservePdbMarkerDirectories.Identity)**\*.pdb" Condition="'@(_PreservePdbMarkerDirectories)' != ''" /> | ||
| </ItemGroup> | ||
| <PropertyGroup Condition="'@(_MergedPayloadFiles)' != ''"> | ||
| <_PreservePdbFileNames>;@(_PreservePdbSourceFiles->'%(Filename).pdb');</_PreservePdbFileNames> | ||
| </PropertyGroup> |
Comment on lines
+42
to
+48
| if (riid == IID_IUnknown || | ||
| riid == IID_IMetaDataImport || | ||
| riid == IID_IMetaDataImport2) | ||
| { | ||
| *ppvObject = static_cast<IMetaDataImport2*>(this); | ||
| return S_OK; | ||
| } |
Comment on lines
+45
to
+48
| { | ||
| *ppvObject = static_cast<IMetaDataImport2*>(this); | ||
| return S_OK; | ||
| } |
Comment on lines
+70
to
+71
| Type testType = ijwNativeDll.GetType("TestClass"); | ||
| MethodInfo throwMethod = testType.GetMethod("ThrowFromManaged"); |
Comment on lines
+77
to
+79
| StackFrame ijwFrame = null; | ||
| foreach (StackFrame frame in new StackTrace(thrown, fNeedFileInfo: true).GetFrames()) | ||
| { |
Comment on lines
+2
to
+12
| <PropertyGroup> | ||
| <!-- A classic Windows PDB (DebugType=Full) is required to exercise the diasymreader path, | ||
| and it can only be emitted on Windows. The test itself is Windows-only. --> | ||
| <DebugType Condition="'$(TargetOS)' == 'windows'">Full</DebugType> | ||
| <DebugSymbols>true</DebugSymbols> | ||
| <Optimize>false</Optimize> | ||
| <!-- DIA isn't used under Native AOT at runtime, but ensure that ILC does create | ||
| line number blobs from full PDB that can be used in runtime stack traces. --> | ||
| <StackTraceLineNumberSupport>true</StackTraceLineNumberSupport> | ||
| <PreservePdbInHelixPayload>true</PreservePdbInHelixPayload> | ||
| </PropertyGroup> |
This was referenced Jul 2, 2026
Member
|
fullpdbstacktrace is failing on CoreCLR, and the tests need to be disabled on Mono |
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.
When resolving line numbers and sequence points for classic PDB-backed modules,
Module::GetISymUnmanagedReaderonmainpasses a real metadata importer into DIA. Materializing that importer can switch metadata access to the RW-backed variant, and later metadata reads can contend on its lock-heavy path.This change avoids that transition by passing a process-wide no-op importer (
NoopMetadataImport) that only satisfies the binder's non-null COM contract. Since it contains no module-linked state, it is a singleton and has no collectible-lifetime coupling.NoopMetadataImportbehavior:IUnknown,IMetaDataImport,IMetaDataImport2and does not exposeIID_IGetIMDInternalImport.AddRef/Releaseare process-lifetime no-ops.E_NOTIMPLin Release.The binder requires a non-null metadata import interface, but the StackTrace/source-line in-proc path does not need metadata signatures from that importer. A no-op importer keeps the binder contract while avoiding the RW swap.
Performance tests
Same repro from issue: https://gist.github.com/jkotas/617109b64d9b0ad52b491cdf021b2f8a
Machine:
Experiment:
Results (avg exceptions/sec):
This matches the target scenario (
full + no PDB) and keeps non-target cells effectively unchanged.Fixes #90563