From d5638239253dd0031dedc3a8f2ff1ed8cb7626e3 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 May 2024 22:02:43 +0200 Subject: [PATCH 1/2] Fix NRE in bulk memmove --- src/coreclr/jit/lower.cpp | 8 +-- .../JitBlue/Runtime_1102138/Runtime_102138.cs | 64 +++++++++++++++++++ .../Runtime_1102138/Runtime_102138.csproj | 8 +++ 3 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.csproj diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 28538fc2b9053..07144f4e7d89f 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -3591,12 +3591,8 @@ void Lowering::MoveCFGCallArgs(GenTreeCall* call) for (CallArg& arg : call->gtArgs.EarlyArgs()) { GenTree* node = arg.GetEarlyNode(); - // Non-value nodes in early args are setup nodes for late args. - if (node->IsValue()) - { - assert(node->OperIsPutArg() || node->OperIsFieldList()); - MoveCFGCallArg(call, node); - } + assert(node->OperIsPutArg() || node->OperIsFieldList()); + MoveCFGCallArg(call, node); } for (CallArg& arg : call->gtArgs.LateArgs()) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs new file mode 100644 index 0000000000000..4ac130a27761a --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs @@ -0,0 +1,64 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +// Generated by Fuzzlyn v1.6 on 2024-05-12 19:09:35 +// Run on X86 Windows +// Seed: 9851999836185511275 +// Reduced from 93.1 KiB to 0.8 KiB in 00:03:30 +// Debug: Runs successfully +// Release: Throws 'System.NullReferenceException' + +public class C0 +{ +} + +public struct S0 +{ + public C0 F0; + public C0 F1; +} + +public struct S1 +{ + public C0 F1; + public S0 F2; + public C0 F3; +} + +public struct S2 +{ + public S1 F4; +} + +public struct S3 +{ + public S2 F0; +} + +public struct S5 +{ + public int F0; +} + +public class Runtime_102138 +{ + public static S3 s_10; + public static byte[] s_11; + + [Fact] + public static int TestEntryPoint() + { + var vr3 = new short[][][]{new short[][]{new short[]{0}}}; + var vr8 = new S5(); + s_10 = M8(vr8, ref s_11, vr3); + return 100; + } + + public static ref S3 M8(S5 argThis, ref byte[] arg0, short[][][] arg1) + { + arg1[0] = new short[][]{new short[]{0}}; + return ref s_10; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.csproj new file mode 100644 index 0000000000000..de6d5e08882e8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.csproj @@ -0,0 +1,8 @@ + + + True + + + + + From 819809ee38d1a7d4f240f36fd709ce4eb3b02473 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Mon, 13 May 2024 22:55:40 +0200 Subject: [PATCH 2/2] Update Runtime_102138.cs --- .../JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs index 4ac130a27761a..680c8c8b861e8 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_1102138/Runtime_102138.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.CompilerServices; +using Xunit; // Generated by Fuzzlyn v1.6 on 2024-05-12 19:09:35 // Run on X86 Windows