Skip to content

R2R + Jit issue when inlining intrinsic methods #115429

@steveharter

Description

@steveharter

Based on a discussion in the open PR, when an intrinsic is JIT'd an AV occurs later in CEEInfo::getArgType when it calls GetModule(sig->scope) which calls GetDynamicResolver(scope)->GetDynamicMethod().

This is a random exception, and only occurs in a release (or checked) build of the runtime when R2R is used on S.P.Corelib. Setting "dotnet_readytorun" to 0 prevents the exception. So when the JIT compiler decides to JIT the intrinsic method that was compiled for R2R, it causes the AV.

Repro:

  1. Clone the PR referenced above
  2. Change the class InstanceCalliHelper in file src\coreclr\System.Private.CoreLib\src\System\Reflection\InstanceCalliHelper.cs so that every [MethodImpl(MethodImplOptions.NoInlining)] is replaced with [MethodImpl(MethodImplOptions.AggressiveInlining)]
  3. Build runtime in release or checked.
  4. Run the test System.Reflection.Tests.MethodInfoTests.TestProperties
  5. You may want to put a breakpoint in MethodDesc::GenerateFunctionPointerCall(DynamicResolver** resolver, COR_ILMETHOD_DECODER** methodILDecoder) (file instancecaii.cpp) to encourage the timing necessary to repro.
  6. Run this a few times until the failure occurs. If the breakpoint is hit in the step above, the exception should occur afterwards.

Sample repro:

cd C:\git\YOURREPO\artifacts\bin\System.Reflection.Tests\Release\net10.0

C:\git\YOURREPO\artifacts\bin\testhost\net10.0-windows-Release-x64\dotnet.exe exec --runtimeconfig System.Reflection.Tests.runtimeconfig.json c:\Users\YOURALIAS\.nuget\packages\microsoft.dotnet.xunitconsolerunner\2.9.0-beta.24475.5\tools\net9.0\xunit.console.dll System.Reflection.Tests.dll -method System.Reflection.Tests.MethodInfoTests.TestProperties

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions