Skip to content

[R2R] Handle missing virtual method signatures - #132337

Merged
agocke merged 2 commits into
dotnet:mainfrom
agocke:fix/crossgen2-dependency-graph-exception
Aug 14, 2026
Merged

agocke merged 2 commits into
dotnet:mainfrom
agocke:fix/crossgen2-dependency-graph-exception

Conversation

@agocke

@agocke agocke commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

  • catch TypeSystemException during inherited interface virtual dependency discovery
  • preserve dependencies discovered before the resolution failure so affected code can fall back to runtime JIT
  • add regression coverage for an interface signature that references a missing assembly

This intentionally keeps the change local to InheritedVirtualMethodsNode; broader resilient-mode policy and diagnostics will be handled separately.

Testing

  • verified the regression test fails before the fix at InheritedVirtualMethodsNode.GetConditionalStaticDependencies
  • Debug ILCompiler.ReadyToRun.Tests build: 0 warnings, 0 errors
  • MissingVirtualSignature: 1 passed, 0 failed

Note

This pull request description was generated with GitHub Copilot.

Keep interface virtual dependency discovery best-effort when a method signature cannot be resolved. Preserve dependencies discovered before the failure so affected code can fall back to runtime JIT.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 6a24ce0e-bddf-4530-8331-432914f41441
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 6a24ce0e-bddf-4530-8331-432914f41441
@agocke
agocke requested a review from jkotas August 14, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves crossgen2/R2R dependency analysis robustness when interface virtual method signature resolution fails (e.g., due to missing referenced assemblies), and adds regression coverage for that scenario.

Changes:

  • Make InheritedVirtualMethodsNode resilient to TypeSystemException during inherited interface virtual dependency discovery by catching and continuing with already-collected dependencies.
  • Fix the R2R test harness to propagate the output directory to dependent CompiledAssembly instances.
  • Add a regression test case (MissingVirtualSignature) exercising an interface method signature that depends on an assembly that is not provided to crossgen2.
Show a summary per file
File Description
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/InheritedVirtualMethodsNode.cs Catch type-resolution failures during interface virtual-slot scanning so compilation can fall back to runtime JIT.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/R2RTestRunner.cs Ensure all Roslyn-compiled assemblies (including dependencies) receive an output directory before compilation.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs Add a regression test covering missing interface signature dependencies.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/MissingVirtualSignature/Input.cs New test input assembly defining the problematic interface signature and an entrypoint method that should still compile.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/MissingVirtualSignature/Dependency.cs New dependency assembly defining the missing return type referenced by the interface signature.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 14, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (2)

src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/MissingVirtualSignature/Input.cs:9

  • This test-case source is compiled with nullable enabled (NullableContextOptions.Enable in R2RTestCaseCompiler). Returning null for a non-nullable reference type will produce CS8603 warnings during the in-test Roslyn compilation. Use null! (or make the return type nullable) to keep the test compilation warning-free while preserving the missing-type reference in the signature.
    MissingSignatureType GetMissingType() => null;

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/InheritedVirtualMethodsNode.cs:141

  • The TypeSystemException handler currently wraps the entire interface-scan block, so a single resolution failure will short-circuit discovery for all remaining implemented interfaces on this type (even if they’re fully resolvable). To keep recovery best-effort and minimize unnecessary JIT fallback, consider moving the try/catch inside the per-interface (or per-method) loop so failures only skip the problematic interface/method and the rest of the interfaces are still analyzed.
            catch (TypeSystemException)
            {
                // TODO: https://github.com/dotnet/runtime/issues/132338 - Gate this recovery on --resilient and report a warning.
            }
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@agocke

agocke commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

/ba-g all failures

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants