OpenJDK / portola / portola
changeset 28106:cb013442a7f3
Merge
author | amurillo |
---|---|
date | Fri, 12 Dec 2014 07:50:34 -0800 |
parents | 0241272e39ed f7963af2ae30 |
children | 587cd87d5c98 f6b1d27113b7 |
files | |
diffstat | 14 files changed, 305 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/java.base/share/native/libjli/java.c Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/src/java.base/share/native/libjli/java.c Fri Dec 12 07:50:34 2014 -0800 @@ -169,6 +169,13 @@ static jlong initialHeapSize = 0; /* inital heap size */ /* + * A minimum -Xss stack size suitable for all platforms. + */ +#ifndef STACK_SIZE_MINIMUM +#define STACK_SIZE_MINIMUM (32 * KB) +#endif + +/* * Entry point. */ int @@ -766,6 +773,14 @@ jlong tmp; if (parse_size(str + 4, &tmp)) { threadStackSize = tmp; + /* + * Make sure the thread stack size is big enough that we won't get a stack + * overflow before the JVM startup code can check to make sure the stack + * is big enough. + */ + if (threadStackSize < STACK_SIZE_MINIMUM) { + threadStackSize = STACK_SIZE_MINIMUM; + } } }
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java Fri Dec 12 07:50:34 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2014, Oracle 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 @@ -141,8 +141,9 @@ public Arguments(String[] args) throws IllegalArgumentException { int argc = 0; - if (args.length < 1) { - throw new IllegalArgumentException("invalid argument count"); + if (args.length == 0) { + help = true; + return; } if ((args[0].compareTo("-?") == 0)
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java Fri Dec 12 07:50:34 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle 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 @@ -238,7 +238,7 @@ } public void stop(ObjectReference throwable) throws InvalidTypeException { - validateMirror(throwable); + validateMirrorOrNull(throwable); // Verify that the given object is a Throwable instance List<ReferenceType> list = vm.classesByName("java.lang.Throwable"); ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);
--- a/jdk/test/ProblemList.txt Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/ProblemList.txt Fri Dec 12 07:50:34 2014 -0800 @@ -135,10 +135,6 @@ # jdk_management -# 8044591 -com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java generic-all -com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java generic-all - # 8058492 java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java Fri Dec 12 07:50:34 2014 -0800 @@ -26,6 +26,7 @@ * @bug 7036199 * @summary Check that GarbageCollectionNotification contents are reasonable * @author Frederic Parain + * @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false * @run main/othervm GarbageCollectionNotificationContentTest */
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java Fri Dec 12 07:50:34 2014 -0800 @@ -26,6 +26,7 @@ * @bug 7036199 * @summary Check that GarbageCollection notification are thrown by every GarbageCollectorMXBean * @author Frederic Parain + * @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false * @run main/othervm GarbageCollectionNotificationTest */
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java Fri Dec 12 07:50:34 2014 -0800 @@ -41,7 +41,7 @@ * @summary Test for VirtualMachine.startManagementAgent and VirtualMachine.startLocalManagementAgent * @library /lib/testlibrary * @run build Application SimpleProvider jdk.testlibrary.* - * @run main StartManagementAgent + * @run main/timeout=300 StartManagementAgent */ /*
--- a/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Fri Dec 12 07:50:34 2014 -0800 @@ -79,24 +79,15 @@ throws IllegalClassFormatException { String tName = Thread.currentThread().getName(); - // In 160_03 and older, transform() is called - // with the "system_loader_lock" held and that - // prevents the bootstrap class loaded from - // running in parallel. If we add a slight sleep - // delay here when the transform() call is not - // main or TestThread, then the deadlock in - // 160_03 and older is much more reproducible. - if (!tName.equals("main") && !tName.equals("TestThread")) { - System.out.println("Thread '" + tName + - "' has called transform()"); - try { - Thread.sleep(500); - } catch (InterruptedException ie) { - } - } - // load additional classes when called from other threads - if (!tName.equals("main")) + // Load additional classes when called from thread 'TestThread' + // When a class is loaded during a callback handling the boot loader, we can + // run into ClassCircularityError if the ClassFileLoadHook is set early enough + // to catch classes needed during class loading, e.g. + // sun.misc.URLClassPath$JarLoader$2. + // The goal of the test is to stress class loading on the test class loaders. + + if (tName.equals("TestThread") && loader != null) { loadClasses(3); }
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java Fri Dec 12 07:50:34 2014 -0800 @@ -29,17 +29,21 @@ * @author Mandy Chung * @author Jaroslav Bachorik * + * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main/othervm Locks */ import java.lang.management.*; import java.util.concurrent.Phaser; +import jdk.testlibrary.LockFreeLogManager; public class Locks { private static final Object objA = new Object(); private static final Object objB = new Object(); private static final Object objC = new Object(); private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean(); + private static final LockFreeLogManager logger = new LockFreeLogManager(); private static boolean testFailed = false; @@ -126,14 +130,14 @@ public void run() { synchronized(objA) { // stop here for LockBThread to hold objB - System.out.println("LockAThread about to block on objB"); + log("LockAThread about to block on objB"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) synchronized(objB) { dummyCounter++; }; } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) - System.out.println("LockAThread about to exit"); + log("LockAThread about to exit"); // Make sure the current thread is not holding any lock assertNoLock(this); } @@ -147,7 +151,7 @@ } public void run() { synchronized(objB) { - System.out.println("LockBThread about to block on objC"); + log("LockBThread about to block on objC"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) // Signal main thread about to block on objC synchronized(objC) { @@ -155,14 +159,14 @@ }; } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) - System.out.println("LockBThread about to exit"); + log("LockBThread about to exit"); // Make sure the current thread is not holding any lock assertNoLock(this); } } private static WaitingThread waiter; - private static Object ready = new Object(); + private static final Object ready = new Object(); private static CheckerThread checker; static class WaitingThread extends Thread { private final Phaser p; @@ -173,9 +177,10 @@ super("WaitingThread"); this.p = p; } + @Override public void run() { synchronized(objC) { - System.out.println("WaitingThread about to wait on objC"); + log("WaitingThread about to wait on objC"); try { // Signal checker thread, about to wait on objC. waiting = false; @@ -188,13 +193,13 @@ } // block until CheckerThread finishes checking - System.out.println("WaitingThread about to block on ready"); + log("WaitingThread about to block on ready"); // signal checker thread that it is about acquire // object ready. p.arriveAndAwaitAdvance(); // Phase 2 (waiting) synchronized(ready) { dummyCounter++; - }; + } } synchronized(objC) { try { @@ -208,7 +213,7 @@ testFailed = true; } } - System.out.println("WaitingThread about to exit waiting on objC 2"); + log("WaitingThread about to exit waiting on objC 2"); } public void waitForWaiting() { @@ -321,10 +326,10 @@ private static ThreadInfo findOwnerInfo(ThreadInfo[] infos, String lock) throws Exception { ThreadInfo ownerInfo = null; - for (int i = 0; i < infos.length; i++) { - String blockedLock = infos[i].getLockName(); + for (ThreadInfo info : infos) { + String blockedLock = info.getLockName(); if (lock.equals(blockedLock)) { - long threadId = infos[i].getLockOwnerId(); + long threadId = info.getLockOwnerId(); if (threadId == -1) { throw new RuntimeException("TEST FAILED: " + lock + " expected to have owner"); @@ -355,14 +360,17 @@ throws Exception { ThreadInfo ownerInfo = null; // Find the thread who is blocking on lock - for (int i = 0; i < infos.length; i++) { - String blockedLock = infos[i].getLockName(); + for (ThreadInfo info : infos) { + String blockedLock = info.getLockName(); if (lock.equals(blockedLock)) { - System.out.print(infos[i].getThreadName() + - " blocked on " + blockedLock); - ownerInfo = infos[i]; + log("%s blocked on %s", info.getThreadName(), blockedLock); + ownerInfo = info; } } + if (ownerInfo == null) { + throw new RuntimeException("TEST FAILED: " + + "Can't retrieve ThreadInfo for the blocked thread"); + } long[] threads = new long[10]; int count = 0; @@ -370,14 +378,18 @@ while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) { ownerInfo = findOwnerInfo(infos, lock); threads[count++] = ownerInfo.getThreadId(); - System.out.println(" Owner = " + ownerInfo.getThreadName() + - " id = " + ownerInfo.getThreadId()); + log(" Owner = %s id = %d", + ownerInfo.getThreadName(), + ownerInfo.getThreadId() + ); lock = ownerInfo.getLockName(); - System.out.print(ownerInfo.getThreadName() + " Id = " + - ownerInfo.getThreadId() + - " blocked on " + lock); + log("%s Id = %d blocked on %s", + ownerInfo.getThreadName(), + ownerInfo.getThreadId(), + lock + ); } - System.out.println(); + log(""); if (count != expectedThreads.length) { throw new RuntimeException("TEST FAILED: " + @@ -385,10 +397,15 @@ } for (int i = 0; i < count; i++) { if (threads[i] != expectedThreads[i]) { - System.out.println("TEST FAILED: " + - "Unexpected thread in the chain " + threads[i] + - " expected to be " + expectedThreads[i]); + log("TEST FAILED: Unexpected thread in the chain %s expected to be %s", + threads[i], + expectedThreads[i] + ); } } } + + private static void log(String format, Object ... args) { + logger.log(format + "%n", args); + } }
--- a/jdk/test/lib/testlibrary/OutputAnalyzerTest.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/lib/testlibrary/OutputAnalyzerTest.java Fri Dec 12 07:50:34 2014 -0800 @@ -112,8 +112,10 @@ } String stdoutPattern = "[a]"; + String stdoutByLinePattern = "a*"; String stderrPattern = "[b]"; String nonExistingPattern = "[c]"; + String byLinePattern = "[ab]*"; // Should match try { @@ -148,6 +150,19 @@ // expected } + if (output.shouldMatchByLine(byLinePattern) != 1) { + throw new Exception("shouldMatchByLine() should find one line"); + } + try { + output.shouldMatchByLine(nonExistingPattern); + throw new Exception("shouldMatchByLine() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + if (output.stdoutShouldMatchByLine(stdoutByLinePattern) != 1) { + throw new Exception("stdoutShouldMatchByLine() should find one line"); + } + // Should not match try { output.shouldNotMatch(nonExistingPattern);
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java Fri Dec 12 07:50:34 2014 -0800 @@ -25,13 +25,9 @@ import static jdk.testlibrary.Asserts.*; -import java.io.ByteArrayOutputStream; - import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -414,8 +410,12 @@ * @return Contents of the output buffer as list of strings */ public List<String> asLines() { + return asLines(getOutput()); + } + + private List<String> asLines(String buffer) { List<String> l = new ArrayList<>(); - String[] a = getOutput().split(Utils.NEW_LINE); + String[] a = buffer.split(Utils.NEW_LINE); for (String string : a) { l.add(string); } @@ -445,6 +445,13 @@ } /** + * @see #stdoutShouldMatchByLine(String, String, String) + */ + public int stdoutShouldMatchByLine(String pattern) { + return stdoutShouldMatchByLine(null, null, pattern); + } + + /** * @see #shouldMatchByLine(String, String, String) */ public int shouldMatchByLineFrom(String from, String pattern) { @@ -474,7 +481,30 @@ * @return Count of lines which match the {@code pattern} */ public int shouldMatchByLine(String from, String to, String pattern) { - List<String> lines = asLines(); + return shouldMatchByLine(getOutput(), from, to, pattern); + } + + /** + * Verify that the stdout contents of output buffer matches the + * {@code pattern} line by line. The whole stdout could be matched or + * just a subset of it. + * + * @param from + * The line from where stdout will be matched. + * Set {@code from} to null for matching from the first line. + * @param to + * The line until where stdout will be matched. + * Set {@code to} to null for matching until the last line. + * @param pattern + * Matching pattern + * @return Count of lines which match the {@code pattern} + */ + public int stdoutShouldMatchByLine(String from, String to, String pattern) { + return shouldMatchByLine(getStdout(), from, to, pattern); + } + + private int shouldMatchByLine(String buffer, String from, String to, String pattern) { + List<String> lines = asLines(buffer); int fromIndex = 0; if (from != null) { @@ -500,4 +530,5 @@ return matchedCount; } + }
--- a/jdk/test/sun/tools/jps/JpsHelper.java Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/sun/tools/jps/JpsHelper.java Fri Dec 12 07:50:34 2014 -0800 @@ -168,10 +168,8 @@ } /** - * Verify jps output contains pids and programs' name information. - * The function will discard any lines that come before the first line with pid. - * This can happen if the JVM outputs a warning message for some reason - * before running jps. + * Verify jps stdout contains only pids and programs' name information. + * jps stderr may contain VM warning messages which will be ignored. * * The output can look like: * 35536 Jps @@ -180,8 +178,10 @@ */ public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception { output.shouldHaveExitValue(0); - int matchedCount = output.shouldMatchByLineFrom(regex, regex); + int matchedCount = output.stdoutShouldMatchByLine(regex); assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex); + output.stderrShouldNotMatch("[E|e]xception"); + output.stderrShouldNotMatch("[E|e]rror"); } /**
--- a/jdk/test/sun/tools/jstat/jstatHelp.sh Fri Dec 12 15:35:21 2014 +0100 +++ b/jdk/test/sun/tools/jstat/jstatHelp.sh Fri Dec 12 07:50:34 2014 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2014, Oracle 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 @@ -22,9 +22,9 @@ # # @test -# @bug 4990825 +# @bug 4990825 6364329 # @run shell jstatHelp.sh -# @summary Test that output of 'jstat -?' matches the usage.out file +# @summary Test that output of 'jstat -?', 'jstat -help' and 'jstat' matches the usage.out file . ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh @@ -38,7 +38,7 @@ diff -w jstat.out ${TESTSRC}/usage.out if [ $? != 0 ] then - echo "Output of jstat -? differ from expected output. Failed." + echo "Output of jstat -? differs from expected output. Failed." exit 1 fi @@ -48,7 +48,17 @@ diff -w jstat.out ${TESTSRC}/usage.out if [ $? != 0 ] then - echo "Output of jstat -help differ from expected output. Failed." + echo "Output of jstat -help differs from expected output. Failed." + exit 1 +fi + +rm -f jstat.out 2>/dev/null +${JSTAT} -J-XX:+UsePerfData > jstat.out 2>&1 + +diff -w jstat.out ${TESTSRC}/usage.out +if [ $? != 0 ] +then + echo "Output of jstat differs from expected output. Failed." exit 1 fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/TooSmallStackSize.java Fri Dec 12 07:50:34 2014 -0800 @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2014, Oracle 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 6762191 + * @summary Setting stack size to 16K causes segmentation fault + * @compile TooSmallStackSize.java + * @run main TooSmallStackSize + */ + +/* + * The primary purpose of this test is to make sure we can run with a 16k stack + * size without crashing. Also this test will determine the minimum allowed + * stack size for the platform (as provided by the JVM error message when a very + * small stack is used), and then verify that the JVM can be launched with that stack + * size without a crash or any error messages. + */ + +public class TooSmallStackSize extends TestHelper { + /* for debugging. Normally false. */ + static final boolean verbose = false; + + static void printTestOutput(TestResult tr) { + System.out.println("*** exitValue = " + tr.exitValue); + for (String x : tr.testOutput) { + System.out.println(x); + } + } + + /* + * Returns the minimum stack size this platform will allowed based on the + * contents of the error message the JVM outputs when too small of a + * -Xss size was used. + * + * The TestResult argument must contain the result of having already run + * the JVM with too small of a stack size. + */ + static String getMinStackAllowed(TestResult tr) { + /* + * The JVM output will contain in one of the lines: + * "The stack size specified is too small, Specify at least 100k" + * Although the actual size will vary. We need to extract this size + * string from the output and return it. + */ + String matchStr = "Specify at least "; + for (String x : tr.testOutput) { + int match_idx = x.indexOf(matchStr); + if (match_idx >= 0) { + int size_start_idx = match_idx + matchStr.length(); + int k_start_idx = x.indexOf("k", size_start_idx); + return x.substring(size_start_idx, k_start_idx + 1); // include the "k" + } + } + + System.out.println("FAILED: Could not get the stack size from the output"); + throw new RuntimeException("test fails"); + } + + /* + * Run the JVM with the specified stack size. + * + * Returns the minimum allowed stack size gleaned from the error message, + * if there is an error message. Otherwise returns the stack size passed in. + */ + static String checkStack(String stackSize) { + String min_stack_allowed; + TestResult tr; + + if (verbose) + System.out.println("*** Testing " + stackSize); + tr = doExec(javaCmd, "-Xss" + stackSize, "-version"); + if (verbose) + printTestOutput(tr); + + if (tr.isOK()) { + System.out.println("PASSED: got no error message with stack size of " + stackSize); + min_stack_allowed = stackSize; + } else { + if (tr.contains("The stack size specified is too small")) { + System.out.println("PASSED: got expected error message with stack size of " + stackSize); + min_stack_allowed = getMinStackAllowed(tr); + } else { + // Likely a crash + System.out.println("FAILED: Did not get expected error message with stack size of " + stackSize); + throw new RuntimeException("test fails"); + } + } + + return min_stack_allowed; + } + + /* + * Run the JVM with the minimum allowed stack size. This should always succeed. + */ + static void checkMinStackAllowed(String stackSize) { + TestResult tr = null; + + if (verbose) + System.out.println("*** Testing " + stackSize); + tr = doExec(javaCmd, "-Xss" + stackSize, "-version"); + if (verbose) + printTestOutput(tr); + + if (tr.isOK()) { + System.out.println("PASSED: VM launched with minimum allowed stack size of " + stackSize); + } else { + // Likely a crash + System.out.println("FAILED: VM failed to launch with minimum allowed stack size of " + stackSize); + throw new RuntimeException("test fails"); + } + } + + public static void main(String... args) { + /* + * The result of a 16k stack size should be a quick exit with a complaint + * that the stack size is too small. However, for some win32 builds, the + * stack is always at least 64k, and this also sometimes is the minimum + * allowed size, so we won't see an error in this case. + * + * This test case will also produce a crash on some platforms if the fix + * for 6762191 is not yet in place. + */ + checkStack("16k"); + + /* + * Try with a 32k stack size, which is the size that the launcher will + * set to if you try setting to anything smaller. This should produce the same + * result as setting to 16k if the fix for 6762191 is in place. + */ + String min_stack_allowed = checkStack("32k"); + + /* + * Try again with a the minimum stack size that was given in the error message + */ + checkMinStackAllowed(min_stack_allowed); + } +}