mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-11 11:59:38 +01:00
8272131: PhaseMacroExpand::generate_slow_arraycopy crash when clone null CallProjections.fallthrough_ioproj
Reviewed-by: neliasso, xliu, thartmann
This commit is contained in:
@@ -831,7 +831,9 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
|
|||||||
}
|
}
|
||||||
|
|
||||||
_igvn.replace_node(_callprojs.fallthrough_memproj, out_mem);
|
_igvn.replace_node(_callprojs.fallthrough_memproj, out_mem);
|
||||||
_igvn.replace_node(_callprojs.fallthrough_ioproj, *io);
|
if (_callprojs.fallthrough_ioproj != NULL) {
|
||||||
|
_igvn.replace_node(_callprojs.fallthrough_ioproj, *io);
|
||||||
|
}
|
||||||
_igvn.replace_node(_callprojs.fallthrough_catchproj, *ctrl);
|
_igvn.replace_node(_callprojs.fallthrough_catchproj, *ctrl);
|
||||||
|
|
||||||
#ifdef ASSERT
|
#ifdef ASSERT
|
||||||
@@ -1095,8 +1097,14 @@ MergeMemNode* PhaseMacroExpand::generate_slow_arraycopy(ArrayCopyNode *ac,
|
|||||||
}
|
}
|
||||||
transform_later(out_mem);
|
transform_later(out_mem);
|
||||||
|
|
||||||
*io = _callprojs.fallthrough_ioproj->clone();
|
// When src is negative and arraycopy is before an infinite loop,_callprojs.fallthrough_ioproj
|
||||||
transform_later(*io);
|
// could be NULL. Skip clone and update NULL fallthrough_ioproj.
|
||||||
|
if (_callprojs.fallthrough_ioproj != NULL) {
|
||||||
|
*io = _callprojs.fallthrough_ioproj->clone();
|
||||||
|
transform_later(*io);
|
||||||
|
} else {
|
||||||
|
*io = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return out_mem;
|
return out_mem;
|
||||||
}
|
}
|
||||||
@@ -1333,7 +1341,9 @@ void PhaseMacroExpand::expand_arraycopy_node(ArrayCopyNode *ac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_igvn.replace_node(_callprojs.fallthrough_memproj, merge_mem);
|
_igvn.replace_node(_callprojs.fallthrough_memproj, merge_mem);
|
||||||
_igvn.replace_node(_callprojs.fallthrough_ioproj, io);
|
if (_callprojs.fallthrough_ioproj != NULL) {
|
||||||
|
_igvn.replace_node(_callprojs.fallthrough_ioproj, io);
|
||||||
|
}
|
||||||
_igvn.replace_node(_callprojs.fallthrough_catchproj, ctrl);
|
_igvn.replace_node(_callprojs.fallthrough_catchproj, ctrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8272131
|
||||||
|
* @requires vm.compiler2.enabled
|
||||||
|
* @summary ArrayCopy with negative index before infinite loop
|
||||||
|
* @run main/othervm -Xbatch -XX:-TieredCompilation
|
||||||
|
* -XX:CompileCommand=compileonly,"*TestIllegalArrayCopyBeforeInfiniteLoop::foo"
|
||||||
|
* compiler.arraycopy.TestIllegalArrayCopyBeforeInfiniteLoop
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.arraycopy;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TestIllegalArrayCopyBeforeInfiniteLoop {
|
||||||
|
private static char src[] = new char[10];
|
||||||
|
private static int count = 0;
|
||||||
|
private static final int iter = 10_000;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
for (int i = 0; i < iter; ++i) {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
if (count != iter) {
|
||||||
|
throw new RuntimeException("test failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void foo() {
|
||||||
|
try {
|
||||||
|
Arrays.copyOfRange(src, -1, 128);
|
||||||
|
do {
|
||||||
|
} while (true);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user