Testcase failure with "Invalid IL code" error
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
We performed a build and ran the ASP.NET Core test suite and multiple test cases failed with the `Invalid IL code` error. Out of 167 test DLLs, 112 DLLs are failing.
## Error Message and Stacktrace
```
System.InvalidProgramException : Invalid IL code in Microsoft.AspNetCore.Hosting.GenericWebHostService:StartAsync (System.Threading.CancellationToken): IL_03f3: ret \n\n
at Microsoft.Extensions.Hosting.Internal.Host.b__16_1(IHostedService service, CancellationToken token)
at Microsoft.Extensions.Hosting.Internal.Host.d__19`1[[Microsoft.Extensions.Hosting.IHostedService, Microsoft.Extensions.Hosting.Abstractions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at Microsoft.Extensions.Hosting.Internal.Host.g__LogAndRethrow|16_3(<>c__DisplayClass16_0&)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Start(IHost host)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1[[AuthSamples.ClaimsTransformer.Startup, ClaimsTransformation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60]].CreateHost(IHostBuilder builder) in /root/ashutosh/asp2/aspnetcore/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 659
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1[[AuthSamples.ClaimsTransformer.Startup, ClaimsTransformation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ConfigureHostBuilder(IHostBuilder hostBuilder) in /root/ashutosh/asp2/aspnetcore/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 404
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1[[AuthSamples.ClaimsTransformer.Startup, ClaimsTransformation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60]].StartServer() in /root/ashutosh/asp2/aspnetcore/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 288
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1[[AuthSamples.ClaimsTransformer.Startup, ClaimsTransformation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60]].CreateDefaultClient(DelegatingHandler[] handlers) in /root/ashutosh/asp2/aspnetcore/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 725
at AuthSamples.FunctionalTests.ClaimsTransformTests..ctor(WebApplicationFactory`1 fixture) in /root/ashutosh/asp2/aspnetcore/src/Security/test/AuthSamples.FunctionalTests/ClaimsTransformTests.cs:line 16
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
```
## Environment
```
Architecture: - ppc64le
OS: - RHEL9
.Net 11 Mono Runtime
```
## Observation
If we disable runtime-async, the tests pass.
```
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 7668c3514e..bd3f1a4103 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -158,7 +158,7 @@
'$(DotNetBuildUseMonoRuntime)' != 'true' AND
'$(TargetOS)' != 'browser' AND
!$(RuntimeIdentifier.StartsWith('browser-'))">
- $(Features);runtime-async=on
+ $(Features);runtime-async=off
@@ -168,7 +168,7 @@
'$(DotNetBuildUseMonoRuntime)' != 'true' AND
'$(TargetOS)' != 'browser' AND
!$(RuntimeIdentifier.StartsWith('browser-'))">
- $(Features);runtime-async=on
+ $(Features);runtime-async=off
```
Similar issue
https://github.com/dotnet/runtime/issues/113789
CC
@tmds
@omajid
Contributor guide
Research direction
Start with Directory.Build.targets and reproduce the ASP.NET Core test failures on ppc64le, RHEL9, and the .NET 11 Mono runtime with runtime-async enabled. Trace the reported path through WebApplicationFactory.cs and ClaimsTransformTests.cs, and compare with runtime issue 113789. Done means the affected test suite runs without InvalidProgramException while runtime-async remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100