Open
Description
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:
- Clone the PR referenced above
- Change the class
InstanceCalliHelper
in filesrc\coreclr\System.Private.CoreLib\src\System\Reflection\InstanceCalliHelper.cs
so that every[MethodImpl(MethodImplOptions.NoInlining)]
is replaced with[MethodImpl(MethodImplOptions.AggressiveInlining)]
- Build runtime in release or checked.
- Run the test System.Reflection.Tests.MethodInfoTests.TestProperties
- You may want to put a breakpoint in
MethodDesc::GenerateFunctionPointerCall(DynamicResolver** resolver, COR_ILMETHOD_DECODER** methodILDecoder)
(fileinstancecaii.cpp
) to encourage the timing necessary to repro. - 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