Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Description

JIT hits assertion '!"Unexpected well known arg to method GDV candidate"' when Guarded Devirtualization encounters methods with AsyncContinuation arguments under tiered PGO with delegate/vtable profiling enabled.

Changes

Added WellKnownArg::AsyncContinuation to the signature compatibility check in isCompatibleMethodGDV:

case WellKnownArg::RetBuffer:
case WellKnownArg::ThisPointer:
case WellKnownArg::AsyncContinuation:  // Added
    // Not part of signature but we still expect to see it here
    continue;

Like RetBuffer and ThisPointer, async continuations are compiler-inserted arguments not reflected in the IL signature. The compatibility check must skip them when matching call arguments against the target method signature.

Consistent with existing handling in fginline.cpp and importer.cpp.

Original prompt

This section details on the original issue you should resolve

<issue_title>Assertion failed '!"Unexpected well known arg to method GDV candidate"</issue_title>
<issue_description>https://dev.azure.com/dnceng-public/public/_build/results?buildId=1266373&view=ms.vss-test-web.build-test-results-tab&runId=35337768&resultId=209882&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab

windows x64 fullpgo method profiling

set DOTNET_TieredCompilation=1
set DOTNET_ReadyToRun=0
set DOTNET_TC_QuickJitForLoops=1
set DOTNET_TieredPGO=1
set DOTNET_JitDelegateProfiling=1
set DOTNET_JitVTableProfiling=1

  Discovering: System.Text.Json.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Text.Json.Tests (found 10198 of 10271 test cases)
  Starting:    System.Text.Json.Tests (parallel test collections = on [4 threads], stop on fail = off)

Assert failure(PID 44644 [0x0000ae64], Thread: 22492 [0x57dc]): Assertion failed '!"Unexpected well known arg to method GDV candidate"' in 'JsonSerializerApiValidation:<SerializeNullException>b__9_1():this' during 'Importation' (IL size 25; hash 0xed53ad00; Tier1)

    File: D:\a\_work\1\s\src\coreclr\jit\importercalls.cpp:7446
    Image: C:\h\w\AB6F09F9\p\dotnet.exe

```</issue_description>

<agent_instructions>Add `WellKnownArg::AsyncContinuation` to the switch in `isCompatibleMethodGDV`</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@AndyAyersMS</author><body>
Also several failures in net11.0-windows-Release-x64-fullpgo_random_gdv_methodprofiling_only-Windows.10.Amd64.Open

DOTNET_JitClassProfiling=0
DOTNET_JitDelegateProfiling=1
DOTNET_JitRandomGuardedDevirtualization=1
DOTNET_JitRandomlyCollect64BitCounts=1
DOTNET_JitVTableProfiling=1
DOTNET_ReadyToRun=0
DOTNET_TC_QuickJitForLoops=1
DOTNET_TieredCompilation=1
DOTNET_TieredPGO=1

Discovering: System.IO.Compression.Brotli.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.IO.Compression.Brotli.Tests (found 109 of 120 test cases)
Starting: System.IO.Compression.Brotli.Tests (parallel test collections = on [4 threads], stop on fail = off)

Assert failure(PID 16680 [0x00004128], Thread: 14112 [0x3720]): Assertion failed '!"Unexpected well known arg to method GDV candidate"' in 'System.IO.Compression.CompressionStreamUnitTestBase:RoundTripWithZLibCompressionOptions(System.String,System.IO.Compression.ZLibCompressionOptions):this' during 'Importation' (IL size 176; hash 0x03f009b8; Tier1-OSR)

File: D:\a\_work\1\s\src\coreclr\jit\importercalls.cpp:7446

Maybe related to dotnet/runtime#123434? -- fyi @hez2010 </body></comment_new>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix assertion failure for GDV candidate Fix JIT assertion for AsyncContinuation in GDV compatibility check Jan 27, 2026
Copilot AI requested a review from jakobbotsch January 27, 2026 11:50
@jakobbotsch jakobbotsch marked this pull request as ready for review January 27, 2026 12:10
Copilot AI review requested due to automatic review settings January 27, 2026 12:10
@jakobbotsch
Copy link
Member

PTAL @dotnet/jit-contrib

Copy link
Contributor

Copilot AI left a comment

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 updates the JIT’s Guarded Devirtualization (GDV) compatibility check to correctly handle compiler-inserted async continuation arguments, preventing an assertion under tiered PGO with delegate/vtable profiling.

Changes:

  • Extend Compiler::isCompatibleMethodGDV to treat WellKnownArg::AsyncContinuation like RetBuffer and ThisPointer as a non-IL-signature argument that should be skipped during compatibility checks.
  • Align GDV compatibility handling with existing async continuation handling already present in fginline.cpp and importer.cpp, removing the "Unexpected well known arg to method GDV candidate" assertion in the reported configurations.

@jkotas jkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI runtime-async labels Jan 27, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI runtime-async

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failed '!"Unexpected well known arg to method GDV candidate"

4 participants