8176505: Wrong assertion 'should be an array copy/clone' in arraycopynode.cpp
Reviewed-by: thartmann, roland
--- a/hotspot/src/share/vm/opto/arraycopynode.cpp Tue Mar 14 12:00:02 2017 +0100
+++ b/hotspot/src/share/vm/opto/arraycopynode.cpp Mon Mar 13 16:07:17 2017 +0100
@@ -225,7 +225,6 @@
Node* dest = in(ArrayCopyNode::Dest);
const Type* src_type = phase->type(src);
const TypeAryPtr* ary_src = src_type->isa_aryptr();
- assert(ary_src != NULL, "should be an array copy/clone");
if (is_arraycopy() || is_copyofrange() || is_copyof()) {
const Type* dest_type = phase->type(dest);
@@ -286,7 +285,8 @@
copy_type = dest_elem;
} else {
- assert (is_clonebasic(), "should be");
+ assert(ary_src != NULL, "should be a clone");
+ assert(is_clonebasic(), "should be");
disjoint_bases = true;
assert(src->is_AddP(), "should be base + off");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestObjectArrayCopy.java Mon Mar 13 16:07:17 2017 +0100
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, SAP SE and/or its affiliates. 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 8176505
+ * @summary Wrong assertion 'should be an array copy/clone' in arraycopynode.cpp
+ *
+ * @run main/othervm -Xbatch -XX:-UseOnStackReplacement compiler.arraycopy.TestObjectArrayCopy
+ *
+ * @author Volker Simonis
+ */
+
+package compiler.arraycopy;
+
+public class TestObjectArrayCopy {
+
+ public static boolean crash(Object src) {
+ String[] dst = new String[1];
+ System.arraycopy(src, 0, dst, 0, 1);
+ return dst[0] == null;
+ }
+
+ public static void main(String[] args) {
+ String[] sa = new String[1];
+ for (int i = 0; i < 20_000; i++) {
+ crash(sa);
+ }
+ }
+}