Fix TypeMapApp R2R test failure: re-process assembly targets in fallback mode#126075
Draft
Fix TypeMapApp R2R test failure: re-process assembly targets in fallback mode#126075
Conversation
…ack mode and skip count=0 entries in CrossGen2 When CrossGen2 encounters an unresolvable TypeMapAssemblyTarget (e.g., the named assembly doesn't exist), it sets exception stubs for the external/proxy type maps but still emits a TypeMapAssemblyTargets entry with count=0. At runtime, HasTypeMapAssemblyTargets returns true (count=0), so hasPrecachedTargets=true, and the original code skips re-processing the assembly-target attributes. That prevents "DoesNotExist" from ever being loaded, silently swallowing the expected FileNotFoundException. Fix 1 (runtime – assemblynative.cpp): Unconditionally re-process assembly-target attributes whenever we are in fallback mode (any precached map is missing or invalid), instead of only when hasPrecachedTargets is false. AssemblyTargetProcessor deduplicates, so re-processing is safe. Fix 2 (CrossGen2 – TypeMapAssemblyTargetsNode.cs): Skip emitting assembly-target entries for groups with no resolved targets (TargetModules.Count==0). With no entry emitted, HasTypeMapAssemblyTargets returns false → hasPrecachedTargets=false → the runtime falls back correctly. Also skip the corresponding dependency imports in ComputeNonRelocationBasedDependencies. Co-authored-by: mangod9 <61718172+mangod9@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/5b28e9e4-36b7-4540-bf60-ae1dad172f85
Copilot
AI
changed the title
[WIP] Fix test failure for Interop/TypeMap/TypeMapApp
Fix TypeMapApp R2R test failure: re-process assembly targets in fallback mode
Mar 25, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries |
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.
Description
In R2R mode,
TypeMap.Validate_MissingAssemblyTargetsilently passes instead of throwingFileNotFoundExceptionwhen an assembly referenced by[TypeMapAssemblyTarget]doesn't exist.Root cause: CrossGen2, when it fails to resolve a target assembly, still emits a
TypeMapAssemblyTargetsR2R entry for that group type with count=0 (because_targetModulesis empty after the failed resolution). At runtime,HasTypeMapAssemblyTargetsfinds this count=0 entry and returnstrue, settinghasPrecachedTargets = true. The original code only re-processes assembly-target attributes when!hasPrecachedTargets, so the fallback that would callspec.LoadAssembly("DoesNotExist")and throw is never reached.Changes
assemblynative.cpp— Remove theif (!hasPrecachedTargets)guard and unconditionally callProcessTypeMapAttributefor assembly-target attributes whenever any precached map is missing/invalid (i.e., the outer fallback block is entered).AssemblyTargetProcessordeduplicates so re-processing is safe. This also handles the "mixed case" where some targets resolved but the external/proxy map failed.TypeMapAssemblyTargetsNode.cs— Skip emittingTypeMapAssemblyTargetsentries for groups whereTargetModules.Count == 0. With no entry emitted,HasTypeMapAssemblyTargetsreturnsfalse→hasPrecachedTargets = false→ the runtime falls back correctly. BothGetDataandComputeNonRelocationBasedDependenciesare updated consistently to skip these entries.The two fixes are complementary: the CrossGen2 fix prevents future images from containing misleading count=0 entries; the runtime fix ensures robustness against any such entries that already exist.
Original prompt
This section details on the original issue you should resolve
<issue_title>Test failure: Interop/TypeMap/TypeMapApp/TypeMapApp.cmd</issue_title>
<issue_description>Failed in: runtime-coreclr r2r-extra 20260321.1
Failed tests: