Sat, 11 Jan 2014 17:18:22 +0000
Added tag jdk8u20-b00 for changeset c89630a122b4
mikael@4989 | 1 | /* |
mikael@4989 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
mikael@4989 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
mikael@4989 | 4 | * |
mikael@4989 | 5 | * This code is free software; you can redistribute it and/or modify it |
mikael@4989 | 6 | * under the terms of the GNU General Public License version 2 only, as |
mikael@4989 | 7 | * published by the Free Software Foundation. |
mikael@4989 | 8 | * |
mikael@4989 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
mikael@4989 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
mikael@4989 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
mikael@4989 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
mikael@4989 | 13 | * accompanied this code). |
mikael@4989 | 14 | * |
mikael@4989 | 15 | * You should have received a copy of the GNU General Public License version |
mikael@4989 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
mikael@4989 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
mikael@4989 | 18 | * |
mikael@4989 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
mikael@4989 | 20 | * or visit www.oracle.com if you need additional information or have any |
mikael@4989 | 21 | * questions. |
mikael@4989 | 22 | */ |
mikael@4989 | 23 | |
mikael@4989 | 24 | /* |
mikael@4989 | 25 | * @test |
mikael@4989 | 26 | * @key regression |
mikael@4989 | 27 | * @bug 8012015 |
mikael@4989 | 28 | * @summary Make sure reserved (but uncommitted) memory is not accessible |
mikael@4989 | 29 | * @library /testlibrary /testlibrary/whitebox |
mikael@4989 | 30 | * @build ReserveMemory |
mikael@4989 | 31 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
mikael@4989 | 32 | * @run main ReserveMemory |
mikael@4989 | 33 | */ |
mikael@4989 | 34 | |
mikael@4989 | 35 | import com.oracle.java.testlibrary.*; |
mikael@4989 | 36 | |
mikael@4989 | 37 | import sun.hotspot.WhiteBox; |
mikael@4989 | 38 | |
mikael@4989 | 39 | public class ReserveMemory { |
mikael@4989 | 40 | private static boolean isWindows() { |
mikael@4989 | 41 | return System.getProperty("os.name").toLowerCase().startsWith("win"); |
mikael@4989 | 42 | } |
mikael@4989 | 43 | |
mikael@5174 | 44 | private static boolean isOsx() { |
mikael@5174 | 45 | return System.getProperty("os.name").toLowerCase().startsWith("mac"); |
mikael@5174 | 46 | } |
mikael@5174 | 47 | |
mikael@4989 | 48 | public static void main(String args[]) throws Exception { |
mikael@4989 | 49 | if (args.length > 0) { |
mikael@5174 | 50 | WhiteBox.getWhiteBox().readReservedMemory(); |
mikael@4989 | 51 | |
mikael@4989 | 52 | throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"); |
mikael@4989 | 53 | } |
mikael@4989 | 54 | |
mikael@4989 | 55 | ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
mikael@4989 | 56 | "-Xbootclasspath/a:.", |
mikael@4989 | 57 | "-XX:+UnlockDiagnosticVMOptions", |
mikael@4989 | 58 | "-XX:+WhiteBoxAPI", |
mseledtsov@5847 | 59 | "-XX:-TransmitErrorReport", |
mikael@4989 | 60 | "ReserveMemory", |
mikael@4989 | 61 | "test"); |
mikael@4989 | 62 | |
mikael@4989 | 63 | OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
mikael@4989 | 64 | if (isWindows()) { |
mikael@4989 | 65 | output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); |
mikael@5174 | 66 | } else if (isOsx()) { |
mikael@5174 | 67 | output.shouldContain("SIGBUS"); |
mikael@4989 | 68 | } else { |
mikael@4989 | 69 | output.shouldContain("SIGSEGV"); |
mikael@4989 | 70 | } |
mikael@4989 | 71 | } |
mikael@4989 | 72 | } |