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

JIT: Assertion failed 'src1->OperIs(GT_LONG)' #8776

Closed
mazong1123 opened this issue Aug 19, 2017 · 7 comments
Closed

JIT: Assertion failed 'src1->OperIs(GT_LONG)' #8776

mazong1123 opened this issue Aug 19, 2017 · 7 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug

Comments

@mazong1123
Copy link
Contributor

Run Windows_NT x86 Checked Build and Test (Jit - CoreFx) CI tests will cause a failure on current master branch code:

20:10:24   Generated serialization assembly for assembly D:\j\workspace\x86_checked_w---92c0aac3\_\fx\bin\AnyOS.AnyCPU.Release\Microsoft.XmlSerializer.Generator.Tests\netstandard\Microsoft.XmlSerializer.Generator.Tests.dll --> 'D:\j\workspace\x86_checked_w---92c0aac3\_\fx\bin\AnyOS.AnyCPU.Release\Microsoft.XmlSerializer.Generator.Tests\netstandard\Microsoft.XmlSerializer.Generator.Tests.XmlSerializers.cs'.
20:10:25   Discovered:  Microsoft.Win32.Registry.Tests
20:10:32   Starting:    Microsoft.Win32.Registry.Tests
20:10:42   
20:10:42 
  Assert failure(PID 788 [0x00000314], Thread: 6912 [0x1b00]): Assertion failed 'src1->OperIs(GT_LONG)' in 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1:Write65_LongEnum(long):ref:this' (IL size 90)
20:10:42   
20:10:42       File: d:\j\workspace\x86_checked_w---92c0aac3\src\jit\lower.cpp Line: 2167
20:10:42       Image: D:\j\workspace\x86_checked_w---92c0aac3\_\fx\bin\testhost\netcoreapp-Windows_NT-Release-x86\dotnet.exe
20:10:42   
20:10:43   Finished running tests.  End time=20:10:43.22, Exit code = 123456789
20:10:44 D:\j\workspace\x86_checked_w---92c0aac3\_\fx\Tools\tests.targets(445,5): warning MSB3073: The command "D:\j\workspace\x86_checked_w---92c0aac3\_\fx\bin/AnyOS.AnyCPU.Release/Microsoft.XmlSerializer.Generator.Tests/netstandard//RunTests.cmd D:\j\workspace\x86_checked_w---92c0aac3\_\fx\bin/testhost/netcoreapp-Windows_NT-Release-x86/" exited with code 123456789. [D:\j\workspace\x86_checked_w---92c0aac3\_\fx\src\Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj]
20:10:44 

It should be introduced 3 days ago.

Please see the CI failure in this PR: dotnet/coreclr#13480

@mikedn
Copy link
Contributor

mikedn commented Aug 19, 2017

The relevant assert code is https://github.com/dotnet/coreclr/blob/3dd1c074f5d89533d8a8e13ea6143a4850752d3e/src/jit/lower.cpp#L2162-L2169

So we have a compare with long operands but the first hasn't been decomposed yet. Hmm...

cc @dotnet/jit-contrib

@mikedn
Copy link
Contributor

mikedn commented Aug 19, 2017

Self contained repro:

enum LongEnum : long
{
    Option0, Option1, Option2
}

[MethodImpl(MethodImplOptions.NoInlining)]
static string Test(LongEnum v)
{
    string s;
    switch (v)
    {
    case LongEnum.Option0: s = "Option0"; break;
    case LongEnum.Option1: s = "Option1"; break;
    case LongEnum.Option2: s = "Option2"; break;
    default: throw new Exception();
    }
    return s;
}

When compiled with optimizations disabled and run with RyuJIT-x86-Checked the assert fires.

@mikedn
Copy link
Contributor

mikedn commented Aug 19, 2017

So we have

               [000028] ------------             *  SWITCH    void  
               [000027] ------------             \--*  CAST      int <- uint <- long
               [000025] ------------                \--*  LCL_VAR   long   V05 tmp1         

and after morph we have

               [000028] -----+------             *  SWITCH    void  
               [000025] C----+------             \--*  LCL_VAR   int    V05 tmp1

Morph has retyped the lclvar node to TYP_INT and dropped the cast. I don't know why morph does this when optimizations are disabled but that's not the problem.
In LowerSwitch we have:
https://github.com/dotnet/coreclr/blob/3dd1c074f5d89533d8a8e13ea6143a4850752d3e/src/jit/lower.cpp#L519-L521

So it gets the type from the lclvar desc. Morph has retyped the lclvar node but the lclvar itself is still TYP_LONG and now switch lowering is generating various new nodes using TYP_LONG, after decomposition was done.

We should probably get the type from the lclvar node instead:

var_types  tempLclType = genActualType(temp->TypeGet());

@danmoseley
Copy link
Member

I repro this also.

@mikedn
Copy link
Contributor

mikedn commented Aug 20, 2017

I repro this also.

In the corefx tests as well or somewhere else?

@danmoseley
Copy link
Member

The CoreFX tests. I misread the report above - it's merely the same case.

@pgavlin
Copy link
Contributor

pgavlin commented Aug 22, 2017

This also repros on JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b425314\b425314 under MinOpts.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Projects
None yet
Development

No branches or pull requests

4 participants