Skip to content

ASP.NET Core Web App shows Unhandled ILCompiler IndexOutOfRangeException error when property group PublishReadyToRun=true in .NET 11 Preview 5 #128413

@Chakolito

Description

@Chakolito

REGRESSION INFO: Works fine with 11.0 Preview 4

INSTALL STEPS:

  1. Clean Win11 x64 25h2 ENU
  2. Install the .NET 11.0 Preview 5 SDK: https://aka.ms/dotnet/11.0.1xx/daily/dotnet-sdk-win-x64.exe
  3. Add feed

Repro Steps

  1. Open Command Prompt
  2. Create a Razor Project.
dotnet new razor
cd razor

3.Open the razor.csproj file and add this code.

<PropertyGroup>
 <PublishTrimmed>false</PublishTrimmed>
 <PublishReadyToRun>true</PublishReadyToRun>
 <PublishSingleFile>true</PublishSingleFile>
 <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
  1. Publish the project with dotnet publish -c release

Actual Result
Error occurs

Image
Error Log
  Razor net11.0 win-x64 failed with 16 error(s) (25.1s) → bin\release\net11.0\win-x64\Razor.dll
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error Unhandled exception. ILCompiler.CodeGenerationFailedException: Code generation failed for method 'Async variant: [Microsoft.AspNetCore.Components.Server]Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSDataStream.CompletePipeAndDisposeStream(Exception)'
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error  ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.IL.Stubs.ILStubMethodIL.GetObject(Int32, NotFoundBehavior) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ILEmitter.cs:line 641
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl.HandleToModuleToken(CORINFO_RESOLVED_TOKEN&, Boolean&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs:line 1481
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl.ComputeMethodWithToken(MethodDesc, CORINFO_RESOLVED_TOKEN&, TypeDesc, Boolean) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs:line 1416
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl.getCallInfo(CORINFO_RESOLVED_TOKEN&, CORINFO_RESOLVED_TOKEN*, CORINFO_METHOD_STRUCT_*, CORINFO_CALLINFO_FLAGS, CORINFO_CALL_INFO*) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs:line 2647
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl._getCallInfo(IntPtr, IntPtr*, CORINFO_RESOLVED_TOKEN*, CORINFO_RESOLVED_TOKEN*, CORINFO_METHOD_STRUCT_*, CORINFO_CALLINFO_FLAGS, CORINFO_CALL_INFO*) in /_/src/runtime/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs:line 2551
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    --- End of inner exception stack trace ---
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode, MethodIL) in /_/src/runtime/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs:line 372
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo, Logger) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs:line 877
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass53_0.<ComputeDependencyNodeDependencies>g__CompileOneMethod|6(DependencyNodeCore`1, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 972
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass53_0.<ComputeDependencyNodeDependencies>g__CompileOnThread|5(Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 893
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass53_0.<ComputeDependencyNodeDependencies>g__CompilationThread|4(Object) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 877
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at System.Threading.Thread.StartThread(IntPtr) in /_/src/runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs:line 443
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(515,5): error    at System.Threading.Thread.ThreadEntryPoint(IntPtr) in /_/src/runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs:line 189
    C:\Program Files\dotnet\sdk\11.0.100-preview.5.26268.112\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(390,5): error NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the PublishReadyToRun property to false.

Note:

  1. Workaround for this error is to set the PublishReadyToRun property to false or run dotnet publish -c Release -p:PublishReadyToRun=false
  2. This also repro with MVC/WebAPI/Blazor.

Expected:
No error will occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions