author | tpivovarova |
Tue, 12 Jul 2016 18:24:48 +0300 | |
changeset 40059 | c2304140ed64 |
parent 38152 | hotspot/test/compiler/runtime/8010927/Test8010927.java@80e5da81fb2c |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
4 |
* |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
8 |
* |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
13 |
* accompanied this code). |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
14 |
* |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
18 |
* |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
21 |
* questions. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
22 |
*/ |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
23 |
|
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
24 |
/* |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
25 |
* @test |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
26 |
* @bug 8010927 |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
27 |
* @summary Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
29678
diff
changeset
|
28 |
* @library /test/lib /testlibrary |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
40059 | 30 |
* @build compiler.runtime.Test8010927 |
31 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
|
32 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
33 |
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions |
|
34 |
* -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xmx64m -XX:NewSize=20971520 |
|
35 |
* -XX:MaxNewSize=32m -XX:-UseTLAB -XX:-UseAdaptiveSizePolicy |
|
36 |
* compiler.runtime.Test8010927 |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
37 |
*/ |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
38 |
|
40059 | 39 |
package compiler.runtime; |
40 |
||
41 |
import jdk.internal.misc.Unsafe; |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
42 |
import sun.hotspot.WhiteBox; |
40059 | 43 |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
44 |
import java.lang.reflect.Field; |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
45 |
|
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
46 |
/** |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
47 |
* The test creates uncommitted space between oldgen and young gen |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
48 |
* by specifying MaxNewSize bigger than NewSize. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
49 |
* NewSize = 20971520 = (512*4K) * 10 for 4k pages |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
50 |
* Then it tries to execute arraycopy() with elements type check |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
51 |
* to the array at the end of survive space near unused space. |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
52 |
*/ |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
53 |
|
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
54 |
public class Test8010927 { |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
55 |
|
40059 | 56 |
private static final Unsafe U; |
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
57 |
|
40059 | 58 |
static { |
59 |
try { |
|
60 |
Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
|
61 |
unsafe.setAccessible(true); |
|
62 |
U = (Unsafe) unsafe.get(null); |
|
63 |
} catch (Exception e) { |
|
64 |
throw new Error(e); |
|
65 |
} |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
66 |
} |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
67 |
|
40059 | 68 |
public static Object[] o; |
69 |
||
70 |
public static final boolean debug = Boolean.getBoolean("debug"); |
|
71 |
||
72 |
// 2 different obect arrays but same element types |
|
73 |
static Test8010927[] masterA; |
|
74 |
static Object[] masterB; |
|
75 |
static final Test8010927 elem = new Test8010927(); |
|
76 |
static final WhiteBox wb = WhiteBox.getWhiteBox(); |
|
77 |
||
78 |
static final int obj_header_size = U.ARRAY_OBJECT_BASE_OFFSET; |
|
79 |
static final int heap_oop_size = wb.getHeapOopSize(); |
|
80 |
static final int card_size = 512; |
|
81 |
static final int one_card = (card_size - obj_header_size) / heap_oop_size; |
|
82 |
||
83 |
static final int surv_size = 2112 * 1024; |
|
84 |
||
85 |
// The size is big to not fit into survive space. |
|
86 |
static final Object[] cache = new Object[(surv_size / card_size)]; |
|
87 |
||
88 |
public static void main(String[] args) { |
|
89 |
masterA = new Test8010927[one_card]; |
|
90 |
masterB = new Object[one_card]; |
|
91 |
for (int i = 0; i < one_card; ++i) { |
|
92 |
masterA[i] = elem; |
|
93 |
masterB[i] = elem; |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
94 |
} |
40059 | 95 |
|
96 |
// Move cache[] to the old gen. |
|
97 |
long low_limit = wb.getObjectAddress(cache); |
|
98 |
System.gc(); |
|
99 |
// Move 'cache' to oldgen. |
|
100 |
long upper_limit = wb.getObjectAddress(cache); |
|
101 |
if ((low_limit - upper_limit) > 0) { // substaction works with unsigned values |
|
102 |
// OldGen is placed before youngger for ParallelOldGC. |
|
103 |
upper_limit = low_limit + 21000000l; // +20971520 |
|
104 |
} |
|
105 |
// Each A[one_card] size is 512 bytes, |
|
106 |
// it will take about 40000 allocations to trigger GC. |
|
107 |
// cache[] has 8192 elements so GC should happen |
|
108 |
// each 5th iteration. |
|
109 |
for (long l = 0; l < 20; l++) { |
|
110 |
fill_heap(); |
|
111 |
if (debug) { |
|
112 |
System.out.println("test oop_disjoint_arraycopy"); |
|
113 |
} |
|
114 |
testA_arraycopy(); |
|
115 |
if (debug) { |
|
116 |
System.out.println("test checkcast_arraycopy"); |
|
117 |
} |
|
118 |
testB_arraycopy(); |
|
119 |
// Execute arraycopy to the topmost array in young gen |
|
120 |
if (debug) { |
|
121 |
int top_index = get_top_address(low_limit, upper_limit); |
|
122 |
if (top_index >= 0) { |
|
123 |
long addr = wb.getObjectAddress(cache[top_index]); |
|
124 |
System.out.println("top_addr: 0x" + Long.toHexString(addr) + ", 0x" + Long.toHexString(addr + 512)); |
|
125 |
} |
|
126 |
} |
|
127 |
} |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
128 |
} |
40059 | 129 |
|
130 |
static void fill_heap() { |
|
131 |
for (int i = 0; i < cache.length; ++i) { |
|
132 |
o = new Test8010927[one_card]; |
|
133 |
System.arraycopy(masterA, 0, o, 0, masterA.length); |
|
134 |
cache[i] = o; |
|
135 |
} |
|
136 |
for (long j = 0; j < 256; ++j) { |
|
137 |
o = new Long[10000]; // to trigger GC |
|
138 |
} |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
139 |
} |
40059 | 140 |
|
141 |
static void testA_arraycopy() { |
|
142 |
for (int i = 0; i < cache.length; ++i) { |
|
143 |
System.arraycopy(masterA, 0, cache[i], 0, masterA.length); |
|
144 |
} |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
145 |
} |
40059 | 146 |
|
147 |
static void testB_arraycopy() { |
|
148 |
for (int i = 0; i < cache.length; ++i) { |
|
149 |
System.arraycopy(masterB, 0, cache[i], 0, masterB.length); |
|
150 |
} |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
151 |
} |
40059 | 152 |
|
153 |
static int get_top_address(long min, long max) { |
|
154 |
int index = -1; |
|
155 |
long addr = min; |
|
156 |
for (int i = 0; i < cache.length; ++i) { |
|
157 |
long test = wb.getObjectAddress(cache[i]); |
|
158 |
if (((test - addr) > 0) && ((max - test) > 0)) { // substaction works with unsigned values |
|
159 |
addr = test; |
|
160 |
index = i; |
|
161 |
} |
|
162 |
} |
|
163 |
return index; |
|
17622
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
164 |
} |
4037daf22a17
8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents:
diff
changeset
|
165 |
} |