Skip to content

RyuJIT: null-ref in program without references #11439

@jakobbotsch

Description

@jakobbotsch
// Debug: Runs successfully
// Release: Throws 'System.NullReferenceException'
struct S0
{
    public uint F1;
    public long F5;
}

public class Program
{
    static short s_2;
    static S0 s_3;
    public static void Main()
    {
        short vr0 = s_2;
        M2();
    }

    static void M2()
    {
        int var1 = (sbyte)(s_3.F1 / ((0 & (0 ^ s_3.F5)) | 1));
    }
}

produces for M2:

G_M23184_IG01:
       0F1F440000           nop
       33C0                 xor      rax, rax

G_M23184_IG02:
       488B4010             mov      rax, qword ptr [rax+16]    ; ouch
       48B878292C6346020000 mov      rax, 0x246632C2978
       488B00               mov      rax, gword ptr [rax]
       8B4008               mov      eax, dword ptr [rax+8]

G_M23184_IG03:
       C3                   ret

; Total bytes of code 28, prolog size 5 for method Program:M2()

Maybe related to #10628 though that was closed a while ago in dotnet/coreclr#19125 so opening a new issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions