Mercurial > hg > truffle
annotate test/gc/g1/TestDeferredRSUpdate.java @ 20234:fd94cbe7c5da
8049684: pstack crashes on java core dump
Reviewed-by: sundar, sspitsyn
author | kevinw |
---|---|
date | Mon, 21 Jul 2014 10:40:50 +0100 |
parents | cd43876f692e |
children | e8ba50da0de0 |
rev | line source |
---|---|
20225
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
1 /* |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
4 * |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
8 * |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
13 * accompanied this code). |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
14 * |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
18 * |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
21 * questions. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
22 */ |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
23 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
24 /* |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
25 * @test TestDeferredRSUpdate |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
26 * @bug 8040977 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
27 * @summary Ensure that running with -XX:-G1DeferredRSUpdate does not crash the VM |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
28 * @key gc |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
29 * @library /testlibrary |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
30 */ |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
31 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
32 import com.oracle.java.testlibrary.ProcessTools; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
33 import com.oracle.java.testlibrary.OutputAnalyzer; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
34 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
35 public class TestDeferredRSUpdate { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
36 public static void main(String[] args) throws Exception { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
37 GCTest.main(args); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
38 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
40 "-Xmx10M", |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
41 // G1DeferredRSUpdate is a develop option, but we cannot limit execution of this test to only debug VMs. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
42 "-XX:+IgnoreUnrecognizedVMOptions", |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
43 "-XX:-G1DeferredRSUpdate", |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
44 GCTest.class.getName()); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
45 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
46 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
47 output.shouldHaveExitValue(0); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
48 } |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
49 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
50 static class GCTest { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
51 private static Object[] garbage = new Object[32]; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
52 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
53 public static void main(String [] args) { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
54 System.out.println("Creating garbage"); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
55 // Create 128MB of garbage. This should result in at least one minor GC, with |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
56 // some objects copied to old gen. As references from old to young are installed, |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
57 // the crash due to the use before initialize occurs. |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
58 Object prev = null; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
59 Object prevPrev = null; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
60 for (int i = 0; i < 1024; i++) { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
61 Object[] next = new Object[32 * 1024]; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
62 next[0] = prev; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
63 next[1] = prevPrev; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
64 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
65 Object[] cur = (Object[]) garbage[i % garbage.length]; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
66 if (cur != null) { |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
67 cur[0] = null; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
68 cur[1] = null; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
69 } |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
70 garbage[i % garbage.length] = next; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
71 |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
72 prevPrev = prev; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
73 prev = next; |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
74 } |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
75 System.out.println("Done"); |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
76 } |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
77 } |
cd43876f692e
8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
tschatzl
parents:
diff
changeset
|
78 } |