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

Invalid field sequence in value numbering #62178

Closed
kunalspathak opened this issue Nov 30, 2021 · 3 comments · Fixed by #62632
Closed

Invalid field sequence in value numbering #62178

kunalspathak opened this issue Nov 30, 2021 · 3 comments · Fixed by #62632
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@kunalspathak
Copy link
Member

kunalspathak commented Nov 30, 2021

// Found by Antigen
// TestClass
using System.Runtime.InteropServices;

public class TestClass_A
{
  [StructLayout(LayoutKind.Sequential, Size = 1)]
  public struct S1
  {
  }
  
  [StructLayout(LayoutKind.Sequential, Size = 1)]
  public struct S2
  {
  }
  
  private static byte s_byte_3 = 5;
  
  private static S1 s_s1_16 = default(S1);
  
  private static S2 s_s2_17 = default(S2);
  
  private byte byte_19 = 127;
  
  private short short_23 = -2;
  
  private sbyte sbyte_26 = 2;
  
  private S1 s1_32;
  
  private S2 s2_33;
  
  public byte Method33(ref S1 p_s1_865, ref S2 p_s2_866, ref short p_short_867, S1 p_s1_868, out S1 p_s1_869, out S1 p_s1_870, out S1 p_s1_871, S1 p_s1_872, ref sbyte p_sbyte_873, out S1 p_s1_874, ref S2 p_s2_875)
  {
    p_s1_874 = s1_32;
    return s_byte_3;
  }
  
  public byte Method96(ref S2 p_s2_2493, S2 p_s2_2494, ref S1 p_s1_2495, ref S2 p_s2_2496, ref S1 p_s1_2497, short p_short_2498, S2 p_s2_2499, out ushort p_ushort_2500, ref S2 p_s2_2501, S2 p_s2_2502, out S1 p_s1_2503, ref short p_short_2504, bool p_bool_2505)
  {
    p_ushort_2500 = 11;
    return (byte)((int)Method33(ref p_s1_2497, ref s_s2_17, ref short_23, p_s1_2495, out p_s1_2495, out s_s1_16, out s1_32, s_s1_16, ref sbyte_26, out s_s1_16, ref s2_33) % 15 + 4);
  }
  
  public void Method0()
  {
    ushort p_ushort_ = 2;
    S1 p_s1_ = default(S1);
    S2 p_s2_ = default(S2);
    byte_19 = Method96(ref p_s2_, s_s2_17, ref s_s1_16, ref p_s2_, ref s1_32, 19, s2_33, out p_ushort_, ref p_s2_, s_s2_17, out p_s1_, ref short_23, p_bool_2505: true);
  }
  
  public static void Main(string[] args)
  {
    new TestClass_A().Method0();
  }
}

// Test environment:

// COMPlus_JitOptRepeat=*
// COMPlus_JitStress=2
// COMPlus_TieredCompilation=0
Assert failure(PID 25408 [0x00006340], Thread: 2848 [0x0b20]): Assertion failed 'fldSeq2 != nullptr' in 'TestClass_A:Method96(byref,S2,byref,byref,byref,short,S2,byref,byref,S2,byref,byref,bool):ubyte:this' during 'Do value numbering' (IL size 71)

    File: D:\git\dotnet-runtime\src\coreclr\jit\valuenum.cpp Line: 9008
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\corerun.exe
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Nov 30, 2021
@ghost
Copy link

ghost commented Nov 30, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details
// Found by Antigen
// TestClass
using System.Runtime.InteropServices;

public class TestClass_A
{
  [StructLayout(LayoutKind.Sequential, Size = 1)]
  public struct S1
  {
  }
  
  [StructLayout(LayoutKind.Sequential, Size = 1)]
  public struct S2
  {
  }
  
  private static byte s_byte_3 = 5;
  
  private static S1 s_s1_16 = default(S1);
  
  private static S2 s_s2_17 = default(S2);
  
  private byte byte_19 = 127;
  
  private short short_23 = -2;
  
  private sbyte sbyte_26 = 2;
  
  private S1 s1_32;
  
  private S2 s2_33;
  
  public byte Method33(ref S1 p_s1_865, ref S2 p_s2_866, ref short p_short_867, S1 p_s1_868, out S1 p_s1_869, out S1 p_s1_870, out S1 p_s1_871, S1 p_s1_872, ref sbyte p_sbyte_873, out S1 p_s1_874, ref S2 p_s2_875)
  {
  p_s1_874 = s1_32;
  return s_byte_3;
  }
  
  public byte Method96(ref S2 p_s2_2493, S2 p_s2_2494, ref S1 p_s1_2495, ref S2 p_s2_2496, ref S1 p_s1_2497, short p_short_2498, S2 p_s2_2499, out ushort p_ushort_2500, ref S2 p_s2_2501, S2 p_s2_2502, out S1 p_s1_2503, ref short p_short_2504, bool p_bool_2505)
  {
  p_ushort_2500 = 11;
  return (byte)((int)Method33(ref p_s1_2497, ref s_s2_17, ref short_23, p_s1_2495, out p_s1_2495, out s_s1_16, out s1_32, s_s1_16, ref sbyte_26, out s_s1_16, ref s2_33) % 15 + 4);
  }
  
  public void Method0()
  {
  ushort p_ushort_ = 2;
  S1 p_s1_ = default(S1);
  S2 p_s2_ = default(S2);
  byte_19 = Method96(ref p_s2_, s_s2_17, ref s_s1_16, ref p_s2_, ref s1_32, 19, s2_33, out p_ushort_, ref p_s2_, s_s2_17, out p_s1_, ref short_23, p_bool_2505: true);
  }
  
  public static void Main(string[] args)
  {
  new TestClass_A().Method0();
  }
}

// Test environment:

// COMPlus_JitOptRepeat=*
// COMPlus_JitStress=2
// COMPlus_TieredCompilation=0
Assert failure(PID 25408 [0x00006340], Thread: 2848 [0x0b20]): Assertion failed 'fldSeq2 != nullptr' in 'TestClass_A:Method96(byref,S2,byref,byref,byref,short,S2,byref,byref,S2,byref,byref,bool):ubyte:this' during 'Do value numbering' (IL size 71)

    File: D:\git\dotnet-runtime\src\coreclr\jit\valuenum.cpp Line: 9008
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\corerun.exe
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@JulieLeeMSFT JulieLeeMSFT added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Nov 30, 2021
@SingleAccretion
Copy link
Contributor

This is another instance of #62108 (comment), the problematic tree is as follows (the only difference is that this time it is a proper CSE use, not a def):

N026 (  5,  5) [000026] ---XG------- arg8 out+40        |     |  |  |     +--*  IND       byte
N025 (  2,  2) [000025] ----G--N----                    |     |  |  |     |  \--*  ADD       byref
N023 (  1,  1) [000136] ------------                    |     |  |  |     |     +--*  LCL_VAR   ref    V33 cse1         u:2 (last use)
N024 (  1,  1) [000024] ------------                    |     |  |  |     |     \--*  CNS_INT   long   8 Fseq[#FirstElem]

@SingleAccretion SingleAccretion removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Nov 30, 2021
@SingleAccretion SingleAccretion self-assigned this Nov 30, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 7.0.0 milestone Dec 1, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 10, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 13, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Feb 12, 2022
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants