Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More nativeaot constrained call bug(s) #98582

Open
mrvoorhe opened this issue Feb 16, 2024 · 3 comments · May be fixed by #111178
Open

More nativeaot constrained call bug(s) #98582

mrvoorhe opened this issue Feb 16, 2024 · 3 comments · May be fixed by #111178
Labels
area-NativeAOT-coreclr in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@mrvoorhe
Copy link
Contributor

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

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 16, 2024
@ghost
Copy link

ghost commented Feb 16, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: mrvoorhe
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@mrvoorhe
Copy link
Contributor Author

mrvoorhe commented Feb 16, 2024

Here's another test that is similar. I don't know if it's a separate issue or not. It reuses some of the same interfaces that are in the repro project.

AdderImplicit<object> t = default(AdderImplicit<object>);
var check1 = Check<AdderImplicit<object>, IGen1<object>>(t);
Console.WriteLine($"Check1 = {check1}");
t = default(AdderImplicit<object>);
var check2 = Check<AdderImplicit<object>, IGen2<object>>(t);
t = default(AdderImplicit<object>);
Console.WriteLine($"Check2 = {check2}");
var check3 = Check<AdderImplicit<object>, IGen3<object>>(t);
Console.WriteLine($"Check3 = {check3}");
var tt = default(AdderImplicit<Atom>);
var check4 = Check<AdderImplicit<Atom>, Atom>(tt);
Console.WriteLine($"Check4 = {check4}");

    struct AdderImplicit<T> : IAdder<IGen1<T>>, IAdder<IGen2<T>>, IAdder<IGen3<T>>, IAdder<Atom>
    {
        private int _field;

        public int Add(int p)
        {
            _field += p;
            return _field;
        }

        public int PlusPlus()
        {
            return Add(1);
        }
    }

@MichalStrehovsky
Copy link
Member

Likely dup of dotnet/runtimelab#1431 (see blocked tests in issues.targets).

@MichalStrehovsky MichalStrehovsky added this to the Future milestone Feb 17, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Feb 17, 2024
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this issue Jan 7, 2025
@MichalStrehovsky MichalStrehovsky linked a pull request Jan 7, 2025 that will close this issue
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr in-pr There is an active PR which will close this issue when it is merged
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants