From 40c63e8675d2698c8abf9bf2b262e7ece02eacec Mon Sep 17 00:00:00 2001 From: TheRealMDoerr Date: Fri, 5 Dec 2025 12:57:03 +0100 Subject: [PATCH] 8361117: SIGSEGV in LShiftLNode::Ideal due to unexpected dead node --- src/hotspot/share/opto/arraycopynode.cpp | 6 ++ .../jtreg/compiler/c2/Test8361117.java | 61 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/c2/Test8361117.java diff --git a/src/hotspot/share/opto/arraycopynode.cpp b/src/hotspot/share/opto/arraycopynode.cpp index d6cc4057511..6400d87a744 100644 --- a/src/hotspot/share/opto/arraycopynode.cpp +++ b/src/hotspot/share/opto/arraycopynode.cpp @@ -307,7 +307,13 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape, return false; } + Node* hook = new Node(1); + hook->init_req(0, dest_offset); + Node* src_scale = phase->transform(new LShiftXNode(src_offset, phase->intcon(shift))); + + hook->destruct(phase); + Node* dest_scale = phase->transform(new LShiftXNode(dest_offset, phase->intcon(shift))); adr_src = phase->transform(new AddPNode(base_src, base_src, src_scale)); diff --git a/test/hotspot/jtreg/compiler/c2/Test8361117.java b/test/hotspot/jtreg/compiler/c2/Test8361117.java new file mode 100644 index 00000000000..8bd79d07d6b --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/Test8361117.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8361117 + * @summary SIGSEGV in LShiftLNode::Ideal due to unexpected dead node + * + * @run main/othervm -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,compiler.c2.Test8361117::test + * compiler.c2.Test8361117 + */ + +package compiler.c2; + +public class Test8361117 { + public static void test() { + int size = 1000; + int[] arr1 = new int[size]; + int[] arr2 = new int[size]; + for (int i = 0; i < size; i++) { + arr1[i] = i; + } + for (int i = 0; i < size; i += 10) { + for (int j = 0; j < 5; j++) { + int srcPos = i + j; + int destPos = i + j; + int length = 5 - j; + java.lang.System.arraycopy(arr1, srcPos, arr2, destPos, + length); + } + } + } + + public static void main(String[] args) { + for (int i = 0; i < 10_000; i++) { + test(); + } + } +}