Skip to content

Optimizations introduce null reference exception on latest preview 8 daily build #39403

@RossNordby

Description

@RossNordby

With tiered compilation off, optimizations enabled, targeting net5.0 on win10 x64 under latest daily build (f37dd6f, 5.0.0-preview.8.20361.2), calling TestRepro throws a null reference exception:

        struct Container
        {
            public Vector<int> Vector;
            public int Integer;
        }

        static Vector<int> DoAThingByRef(ref Vector<int> s)
        {
            return s + Vector<int>.Zero;
        }
        [MethodImpl(MethodImplOptions.NoInlining)]
        static unsafe Vector<int> Test()
        {
            Container container = default;
            return DoAThingByRef(ref container.Vector);
        }

        public static void TestRepro()
        {
            Test();
        }

The resulting assembly for Test:

 sub         rsp,28h  
 vzeroupper  
 xor         eax,eax  
 vxorps      xmm0,xmm0,xmm0  
 vmovdqu     xmmword ptr [rsp],xmm0  
 vmovdqu     xmmword ptr [rsp+10h],xmm0  
 mov         qword ptr [rsp+20h],rax  
 vxorps      ymm0,ymm0,ymm0  
 vpaddd      ymm0,ymm0,ymmword ptr [0] 🐱‍👤
 vmovupd     ymmword ptr [rcx],ymm0  
 mov         rax,rcx  
 vzeroupper  
 add         rsp,28h  
 ret  

Preview 7 works as expected.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions