Skip to content

More nativeaot constrained call bug(s) #98582

@mrvoorhe

Description

@mrvoorhe

Description

Here's another of our constrained call tests that failed with nativeaot.

Reproduction Steps

  1. Unzip the attached file
    ConsoleApp45.zip

  2. Run dotnet publish

  3. Run .\ConsoleApp45\bin\Release\net8.0\win-x64\publish\ConsoleApp45.exe

Expected behavior

C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45> dotnet run                                   
Check1 = 3
Check2 = 6
Check3 = 9
Check4 = 12
CheckGen1 = 3
CheckGen2 = 6

Actual behavior

PS C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45> dotnet publish
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45\ConsoleApp45.csproj (in 228 ms).
  ConsoleApp45 -> C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45\bin\Release\net8.0\win-x64\ConsoleApp45.dll
  Generating native code
  ILC: Method '[ConsoleApp45]Program.<<Main>$>g__Check|0_0<AdderExplicit`1<__Canon>,__Canon>(AdderExplicit`1<__Canon>)' will always throw because: Invalid IL or CLR metadata
  ILC: Method '[ConsoleApp45]Program.<<Main>$>g__CheckGen2|0_2<AdderExplicit`1<__Canon>>(AdderExplicit`1<__Canon>)' will always throw because: Invalid IL or CLR metadata
  ILC: Method '[ConsoleApp45]Program.<<Main>$>g__CheckGen1|0_1<AdderExplicit`1<__Canon>>(AdderExplicit`1<__Canon>)' will always throw because: Invalid IL or CLR metadata
  ConsoleApp45 -> C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45\bin\Release\net8.0\win-x64\publish\
C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45> .\bin\Release\net8.0\win-x64\publish\ConsoleApp45.exe
Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
   at Internal.Runtime.TypeLoaderExceptionHelper.CreateInvalidProgramException(ExceptionStringID) + 0x31
   at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowInvalidProgramException(ExceptionStringID) + 0x9
   at Program.<<Main>$>g__Check|0_0[T,U](T) + 0xe
   at Program.<Main>$(String[] args) + 0x27
   at ConsoleApp45!<BaseAddress>+0xd2a10
PS C:\UnitySrc\dev\TestGround\ConsoleApp45\ConsoleApp45>

Regression?

I suspect it probably happened with the net7 nativeaot but I don't know for certain. I didn't explicitly check this test back when I was testing net7 nativeaot.

.NET Core is fine. Mono and .NET Framework are also fine.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions