Patche adapted to current surces

This commit is contained in:
Jiri 2017-04-21 09:56:16 +02:00
parent 868631b254
commit 0fb9d78c0f
13 changed files with 1598 additions and 177 deletions

213
6515172-pr3346.patch Normal file
View File

@ -0,0 +1,213 @@
# HG changeset patch
# User shshahma
# Date 1474535080 25200
# Thu Sep 22 02:04:40 2016 -0700
# Node ID baf64c88538f477d7f5a0cf90b670108ac312375
# Parent 62212568179b76b5ebe7b0129ddeed7b268b0bc0
6515172, PR3346: Runtime.availableProcessors() ignores Linux taskset command
Summary: extract processor count from sched_getaffinity mask
Reviewed-by: dholmes, gthornbr
diff --git a/src/os/linux/vm/globals_linux.hpp b/src/os/linux/vm/globals_linux.hpp
--- openjdk/hotspot/src/os/linux/vm/globals_linux.hpp
+++ openjdk/hotspot/src/os/linux/vm/globals_linux.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -47,7 +47,10 @@
"Load DLLs with executable-stack attribute in the VM Thread") \
\
product(bool, UseSHM, false, \
- "Use SYSV shared memory for large pages")
+ "Use SYSV shared memory for large pages") \
+ \
+ diagnostic(bool, PrintActiveCpus, false, \
+ "Print the number of CPUs detected in os::active_processor_count")
//
// Defines Linux-specific default values. The flags are available on all
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -104,6 +104,14 @@
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
+#ifndef _GNU_SOURCE
+ #define _GNU_SOURCE
+ #include <sched.h>
+ #undef _GNU_SOURCE
+#else
+ #include <sched.h>
+#endif
+
// if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
// getrusage() is prepared to handle the associated failure.
#ifndef RUSAGE_THREAD
@@ -5027,12 +5035,42 @@
}
};
+static int os_cpu_count(const cpu_set_t* cpus) {
+ int count = 0;
+ // only look up to the number of configured processors
+ for (int i = 0; i < os::processor_count(); i++) {
+ if (CPU_ISSET(i, cpus)) {
+ count++;
+ }
+ }
+ return count;
+}
+
+// Get the current number of available processors for this process.
+// This value can change at any time during a process's lifetime.
+// sched_getaffinity gives an accurate answer as it accounts for cpusets.
+// If anything goes wrong we fallback to returning the number of online
+// processors - which can be greater than the number available to the process.
int os::active_processor_count() {
- // Linux doesn't yet have a (official) notion of processor sets,
- // so just return the number of online processors.
- int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
- assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
- return online_cpus;
+ cpu_set_t cpus; // can represent at most 1024 (CPU_SETSIZE) processors
+ int cpus_size = sizeof(cpu_set_t);
+ int cpu_count = 0;
+
+ // pid 0 means the current thread - which we have to assume represents the process
+ if (sched_getaffinity(0, cpus_size, &cpus) == 0) {
+ cpu_count = os_cpu_count(&cpus);
+ if (PrintActiveCpus) {
+ tty->print_cr("active_processor_count: sched_getaffinity processor count: %d", cpu_count);
+ }
+ }
+ else {
+ cpu_count = ::sysconf(_SC_NPROCESSORS_ONLN);
+ warning("sched_getaffinity failed (%s)- using online processor count (%d) "
+ "which may exceed available processors", strerror(errno), cpu_count);
+ }
+
+ assert(cpu_count > 0 && cpu_count <= processor_count(), "sanity check");
+ return cpu_count;
}
void os::set_native_thread_name(const char *name) {
diff --git a/test/runtime/os/AvailableProcessors.java b/test/runtime/os/AvailableProcessors.java
new file mode 100644
--- /dev/null
+++ openjdk/hotspot/test/runtime/os/AvailableProcessors.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+import java.io.File;
+import com.oracle.java.testlibrary.ProcessTools;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import java.util.ArrayList;
+
+/*
+ * @test
+ * @bug 6515172
+ * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
+ * @requires os.family == "linux"
+ * @library /testlibrary
+ * @build com.oracle.java.testlibrary.*
+ * @run driver AvailableProcessors
+ */
+public class AvailableProcessors {
+
+ static final String SUCCESS_STRING = "Found expected processors: ";
+
+ public static void main(String[] args) throws Throwable {
+ if (args.length > 0)
+ checkProcessors(Integer.parseInt(args[0]));
+ else {
+ // run ourselves under different cpu configurations
+ // using the taskset command
+ String taskset;
+ final String taskset1 = "/bin/taskset";
+ final String taskset2 = "/usr/bin/taskset";
+ if (new File(taskset1).exists())
+ taskset = taskset1;
+ else if (new File(taskset2).exists())
+ taskset = taskset2;
+ else {
+ System.out.println("Skipping test: could not find taskset command");
+ return;
+ }
+
+ int available = Runtime.getRuntime().availableProcessors();
+
+ if (available == 1) {
+ System.out.println("Skipping test: only one processor available");
+ return;
+ }
+
+ // Get the java command we want to execute
+ // Enable logging for easier failure diagnosis
+ ProcessBuilder master =
+ ProcessTools.createJavaProcessBuilder(false,
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+PrintActiveCpus",
+ "AvailableProcessors");
+
+ int[] expected = new int[] { 1, available/2, available-1, available };
+
+ for (int i : expected) {
+ System.out.println("Testing for " + i + " processors ...");
+ int max = i - 1;
+ ArrayList<String> cmdline = new ArrayList<>(master.command());
+ // prepend taskset command
+ cmdline.add(0, "0-" + max);
+ cmdline.add(0, "-c");
+ cmdline.add(0, taskset);
+ // append expected processor count
+ cmdline.add(String.valueOf(i));
+ ProcessBuilder pb = new ProcessBuilder(cmdline);
+ System.out.println("Final command line: " +
+ ProcessTools.getCommandLine(pb));
+ OutputAnalyzer output = ProcessTools.executeProcess(pb);
+ output.shouldContain(SUCCESS_STRING);
+ }
+ }
+ }
+
+ static void checkProcessors(int expected) {
+ int available = Runtime.getRuntime().availableProcessors();
+ if (available != expected)
+ throw new Error("Expected " + expected + " processors, but found "
+ + available);
+ else
+ System.out.println(SUCCESS_STRING + available);
+ }
+}

911
8144566-pr3352.patch Normal file
View File

@ -0,0 +1,911 @@
# HG changeset patch
# User rpatil
# Date 1474623897 -19800
# Fri Sep 23 15:14:57 2016 +0530
# Node ID fb617df8fbac42e962219e45cbd29b15b5ecdc63
# Parent d41592af9af3790fe5eee30ce686d85cff09c942
8144566, PR3352: Custom HostnameVerifier disables SNI extension
Reviewed-by: coffeys
diff --git a/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/share/classes/sun/security/ssl/SSLSocketImpl.java
--- openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
+++ openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, 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
@@ -220,6 +220,11 @@
Collections.<SNIServerName>emptyList();
Collection<SNIMatcher> sniMatchers =
Collections.<SNIMatcher>emptyList();
+ // Is the serverNames set to empty with SSLParameters.setServerNames()?
+ private boolean noSniExtension = false;
+
+ // Is the sniMatchers set to empty with SSLParameters.setSNIMatchers()?
+ private boolean noSniMatcher = false;
/*
* READ ME * READ ME * READ ME * READ ME * READ ME * READ ME *
@@ -666,6 +671,11 @@
}
super.connect(endpoint, timeout);
+
+ if (host == null || host.length() == 0) {
+ useImplicitHost(false);
+ }
+
doneConnect();
}
@@ -2158,41 +2168,61 @@
output.r.setVersion(protocolVersion);
}
+ //
+ // ONLY used by ClientHandshaker for the server hostname during handshaking
+ //
synchronized String getHost() {
// Note that the host may be null or empty for localhost.
if (host == null || host.length() == 0) {
- if (!trustNameService) {
- // If the local name service is not trustworthy, reverse host
- // name resolution should not be performed for endpoint
- // identification. Use the application original specified
- // hostname or IP address instead.
- host = getOriginalHostname(getInetAddress());
- } else {
- host = getInetAddress().getHostName();
- }
+ useImplicitHost(true);
}
return host;
}
/*
- * Get the original application specified hostname.
+ * Try to set and use the implicit specified hostname
*/
- private static String getOriginalHostname(InetAddress inetAddress) {
- /*
- * Get the original hostname via sun.misc.SharedSecrets.
- */
+ private synchronized void useImplicitHost(boolean noSniUpdate) {
+
+ // Note: If the local name service is not trustworthy, reverse
+ // host name resolution should not be performed for endpoint
+ // identification. Use the application original specified
+ // hostname or IP address instead.
+
+ // Get the original hostname via jdk.internal.misc.SharedSecrets
+ InetAddress inetAddress = getInetAddress();
+ if (inetAddress == null) { // not connected
+ return;
+ }
+
JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
String originalHostname = jna.getOriginalHostName(inetAddress);
+ if ((originalHostname != null) &&
+ (originalHostname.length() != 0)) {
- /*
- * If no application specified hostname, use the IP address.
- */
- if (originalHostname == null || originalHostname.length() == 0) {
- originalHostname = inetAddress.getHostAddress();
+ host = originalHostname;
+ if (!noSniUpdate && serverNames.isEmpty() && !noSniExtension) {
+ serverNames =
+ Utilities.addToSNIServerNameList(serverNames, host);
+
+ if (!roleIsServer &&
+ (handshaker != null) && !handshaker.started()) {
+ handshaker.setSNIServerNames(serverNames);
+ }
+ }
+
+ return;
}
- return originalHostname;
+ // No explicitly specified hostname, no server name indication.
+ if (!trustNameService) {
+ // The local name service is not trustworthy, use IP address.
+ host = inetAddress.getHostAddress();
+ } else {
+ // Use the underlying reverse host name resolution service.
+ host = getInetAddress().getHostName();
+ }
}
@@ -2205,6 +2235,10 @@
this.host = host;
this.serverNames =
Utilities.addToSNIServerNameList(this.serverNames, this.host);
+
+ if (!roleIsServer && (handshaker != null) && !handshaker.started()) {
+ handshaker.setSNIServerNames(serverNames);
+ }
}
/**
@@ -2571,8 +2605,21 @@
// the super implementation does not handle the following parameters
params.setEndpointIdentificationAlgorithm(identificationProtocol);
params.setAlgorithmConstraints(algorithmConstraints);
- params.setSNIMatchers(sniMatchers);
- params.setServerNames(serverNames);
+
+ if (sniMatchers.isEmpty() && !noSniMatcher) {
+ // 'null' indicates none has been set
+ params.setSNIMatchers(null);
+ } else {
+ params.setSNIMatchers(sniMatchers);
+ }
+
+ if (serverNames.isEmpty() && !noSniExtension) {
+ // 'null' indicates none has been set
+ params.setServerNames(null);
+ } else {
+ params.setServerNames(serverNames);
+ }
+
params.setUseCipherSuitesOrder(preferLocalCipherSuites);
return params;
@@ -2592,11 +2639,13 @@
List<SNIServerName> sniNames = params.getServerNames();
if (sniNames != null) {
+ noSniExtension = sniNames.isEmpty();
serverNames = sniNames;
}
Collection<SNIMatcher> matchers = params.getSNIMatchers();
if (matchers != null) {
+ noSniMatcher = matchers.isEmpty();
sniMatchers = matchers;
}
diff --git a/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java b/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
new file mode 100644
--- /dev/null
+++ openjdk/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/**
+ * @test
+ * @bug 8144566
+ * @summary Custom HostnameVerifier disables SNI extension
+ * @run main/othervm BestEffortOnLazyConnected
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.nio.channels.*;
+import java.util.*;
+import java.net.*;
+import javax.net.ssl.*;
+
+public class BestEffortOnLazyConnected {
+
+ /*
+ * =============================================================
+ * Set the various variables needed for the tests, then
+ * specify what tests to run on each side.
+ */
+
+ /*
+ * Should we run the client or server in a separate thread?
+ * Both sides can throw exceptions, but do you have a preference
+ * as to which side should be the main thread.
+ */
+ private static final boolean separateServerThread = true;
+
+ /*
+ * Where do we find the keystores?
+ */
+ private static final String pathToStores = "../../../../sun/security/ssl/etc";
+ private static final String keyStoreFile = "keystore";
+ private static final String trustStoreFile = "truststore";
+ private static final String passwd = "passphrase";
+
+ /*
+ * Is the server ready to serve?
+ */
+ private static volatile boolean serverReady = false;
+
+ /*
+ * Turn on SSL debugging?
+ */
+ private static final boolean debug = false;
+
+ /*
+ * the fully qualified domain name of localhost
+ */
+ private static String hostname = null;
+
+ /*
+ * If the client or server is doing some kind of object creation
+ * that the other side depends on, and that thread prematurely
+ * exits, you may experience a hang. The test harness will
+ * terminate all hung threads after its timeout has expired,
+ * currently 3 minutes by default, but you might try to be
+ * smart about it....
+ */
+
+ /*
+ * Define the server side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ private void doServerSide() throws Exception {
+ SSLServerSocketFactory sslssf =
+ (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+ try (SSLServerSocket sslServerSocket =
+ (SSLServerSocket) sslssf.createServerSocket(serverPort)) {
+
+ serverPort = sslServerSocket.getLocalPort();
+
+ /*
+ * Signal Client, we're ready for his connect.
+ */
+ serverReady = true;
+
+ try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
+ InputStream sslIS = sslSocket.getInputStream();
+ OutputStream sslOS = sslSocket.getOutputStream();
+
+ sslIS.read();
+ sslOS.write(85);
+ sslOS.flush();
+
+ ExtendedSSLSession session =
+ (ExtendedSSLSession)sslSocket.getSession();
+ if (session.getRequestedServerNames().isEmpty()) {
+ throw new Exception("No expected Server Name Indication");
+ }
+ }
+ }
+ }
+
+ /*
+ * Define the client side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ private void doClientSide() throws Exception {
+
+ /*
+ * Wait for server to get started.
+ */
+ while (!serverReady) {
+ Thread.sleep(50);
+ }
+
+ SSLSocketFactory sslsf =
+ (SSLSocketFactory) SSLSocketFactory.getDefault();
+
+ try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) {
+
+ sslSocket.connect(new InetSocketAddress(hostname, serverPort), 0);
+
+ InputStream sslIS = sslSocket.getInputStream();
+ OutputStream sslOS = sslSocket.getOutputStream();
+
+ sslOS.write(280);
+ sslOS.flush();
+ sslIS.read();
+ }
+ }
+
+
+ /*
+ * =============================================================
+ * The remainder is just support stuff
+ */
+
+ // use any free port by default
+ private volatile int serverPort = 0;
+
+ private volatile Exception serverException = null;
+ private volatile Exception clientException = null;
+
+ public static void main(String[] args) throws Exception {
+ String keyFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + keyStoreFile;
+ String trustFilename =
+ System.getProperty("test.src", ".") + "/" + pathToStores +
+ "/" + trustStoreFile;
+
+ System.setProperty("javax.net.ssl.keyStore", keyFilename);
+ System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+ System.setProperty("javax.net.ssl.trustStore", trustFilename);
+ System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+ if (debug) {
+ System.setProperty("javax.net.debug", "all");
+ }
+
+ try {
+ hostname = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException uhe) {
+ System.out.println(
+ "Ignore the test as the local hostname cannot be determined");
+
+ return;
+ }
+
+ System.out.println(
+ "The fully qualified domain name of the local host is " +
+ hostname);
+ // Ignore the test if the hostname does not sound like a domain name.
+ if ((hostname == null) || hostname.isEmpty() ||
+ hostname.startsWith("localhost") ||
+ Character.isDigit(hostname.charAt(hostname.length() - 1))) {
+
+ System.out.println("Ignore the test as the local hostname " +
+ "cannot be determined as fully qualified domain name");
+
+ return;
+ }
+
+ /*
+ * Start the tests.
+ */
+ new BestEffortOnLazyConnected();
+ }
+
+ private Thread clientThread = null;
+ private Thread serverThread = null;
+
+ /*
+ * Primary constructor, used to drive remainder of the test.
+ *
+ * Fork off the other side, then do your work.
+ */
+ BestEffortOnLazyConnected() throws Exception {
+ try {
+ if (separateServerThread) {
+ startServer(true);
+ startClient(false);
+ } else {
+ startClient(true);
+ startServer(false);
+ }
+ } catch (Exception e) {
+ // swallow for now. Show later
+ }
+
+ /*
+ * Wait for other side to close down.
+ */
+ if (separateServerThread) {
+ serverThread.join();
+ } else {
+ clientThread.join();
+ }
+
+ /*
+ * When we get here, the test is pretty much over.
+ * Which side threw the error?
+ */
+ Exception local;
+ Exception remote;
+ String whichRemote;
+
+ if (separateServerThread) {
+ remote = serverException;
+ local = clientException;
+ whichRemote = "server";
+ } else {
+ remote = clientException;
+ local = serverException;
+ whichRemote = "client";
+ }
+
+ /*
+ * If both failed, return the curthread's exception, but also
+ * print the remote side Exception
+ */
+ if ((local != null) && (remote != null)) {
+ System.out.println(whichRemote + " also threw:");
+ remote.printStackTrace();
+ System.out.println();
+ throw local;
+ }
+
+ if (remote != null) {
+ throw remote;
+ }
+
+ if (local != null) {
+ throw local;
+ }
+ }
+
+ private void startServer(boolean newThread) throws Exception {
+ if (newThread) {
+ serverThread = new Thread() {
+ public void run() {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ /*
+ * Our server thread just died.
+ *
+ * Release the client, if not active already...
+ */
+ System.err.println("Server died...");
+ serverReady = true;
+ serverException = e;
+ }
+ }
+ };
+ serverThread.start();
+ } else {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ serverException = e;
+ } finally {
+ serverReady = true;
+ }
+ }
+ }
+
+ private void startClient(boolean newThread) throws Exception {
+ if (newThread) {
+ clientThread = new Thread() {
+ public void run() {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ /*
+ * Our client thread just died.
+ */
+ System.err.println("Client died...");
+ clientException = e;
+ }
+ }
+ };
+ clientThread.start();
+ } else {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ clientException = e;
+ }
+ }
+ }
+}
diff --git a/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java b/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
new file mode 100644
--- /dev/null
+++ openjdk/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 8144566
+ * @summary Custom HostnameVerifier disables SNI extension
+ * @run main/othervm ImpactOnSNI
+ */
+
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+
+public class ImpactOnSNI {
+
+ /*
+ * =============================================================
+ * Set the various variables needed for the tests, then
+ * specify what tests to run on each side.
+ */
+
+ /*
+ * Should we run the client or server in a separate thread?
+ * Both sides can throw exceptions, but do you have a preference
+ * as to which side should be the main thread.
+ */
+ private static final boolean separateServerThread = true;
+
+ /*
+ * Where do we find the keystores?
+ */
+ private static final String pathToStores =
+ "../../../../../../sun/security/ssl/etc";
+ private static final String keyStoreFile = "keystore";
+ private static final String trustStoreFile = "truststore";
+ private static final String passwd = "passphrase";
+
+ /*
+ * Is the server ready to serve?
+ */
+ private static volatile boolean serverReady = false;
+
+ /*
+ * Is the connection ready to close?
+ */
+ private static volatile boolean closeReady = false;
+
+ /*
+ * Turn on SSL debugging?
+ */
+ private static final boolean debug = false;
+
+ /*
+ * Message posted
+ */
+ private static final String postMsg = "HTTP post on a https server";
+
+ /*
+ * the fully qualified domain name of localhost
+ */
+ private static String hostname = null;
+
+ /*
+ * If the client or server is doing some kind of object creation
+ * that the other side depends on, and that thread prematurely
+ * exits, you may experience a hang. The test harness will
+ * terminate all hung threads after its timeout has expired,
+ * currently 3 minutes by default, but you might try to be
+ * smart about it....
+ */
+
+ /*
+ * Define the server side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ private void doServerSide() throws Exception {
+ SSLServerSocketFactory sslssf =
+ (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+ try (SSLServerSocket sslServerSocket =
+ (SSLServerSocket)sslssf.createServerSocket(serverPort)) {
+
+ serverPort = sslServerSocket.getLocalPort();
+
+ /*
+ * Signal Client, we're ready for his connect.
+ */
+ serverReady = true;
+
+ /*
+ * Accept connections
+ */
+ try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
+ InputStream sslIS = sslSocket.getInputStream();
+ OutputStream sslOS = sslSocket.getOutputStream();
+ BufferedReader br =
+ new BufferedReader(new InputStreamReader(sslIS));
+ PrintStream ps = new PrintStream(sslOS);
+
+ // process HTTP POST request from client
+ System.out.println("status line: " + br.readLine());
+ String msg = null;
+ while ((msg = br.readLine()) != null && msg.length() > 0);
+
+ msg = br.readLine();
+ if (msg.equals(postMsg)) {
+ ps.println("HTTP/1.1 200 OK\n\n");
+ } else {
+ ps.println("HTTP/1.1 500 Not OK\n\n");
+ }
+ ps.flush();
+
+ ExtendedSSLSession session =
+ (ExtendedSSLSession)sslSocket.getSession();
+ if (session.getRequestedServerNames().isEmpty()) {
+ throw new Exception("No expected Server Name Indication");
+ }
+
+ // close the socket
+ while (!closeReady) {
+ Thread.sleep(50);
+ }
+ }
+ }
+ }
+
+ /*
+ * Define the client side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ private void doClientSide() throws Exception {
+ /*
+ * Wait for server to get started.
+ */
+ while (!serverReady) {
+ Thread.sleep(50);
+ }
+
+ // Send HTTP POST request to server
+ URL url = new URL("https://" + hostname + ":" + serverPort);
+
+ HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
+ HttpsURLConnection http = (HttpsURLConnection)url.openConnection();
+ http.setDoOutput(true);
+
+ http.setRequestMethod("POST");
+ PrintStream ps = new PrintStream(http.getOutputStream());
+ try {
+ ps.println(postMsg);
+ ps.flush();
+ if (http.getResponseCode() != 200) {
+ throw new RuntimeException("test Failed");
+ }
+ } finally {
+ ps.close();
+ http.disconnect();
+ closeReady = true;
+ }
+ }
+
+ private static class NameVerifier implements HostnameVerifier {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ }
+
+ /*
+ * =============================================================
+ * The remainder is just support stuff
+ */
+
+ // use any free port by default
+ private volatile int serverPort = 0;
+
+ private volatile Exception serverException = null;
+ private volatile Exception clientException = null;
+
+ public static void main(String[] args) throws Exception {
+ String keyFilename =
+ System.getProperty("test.src", "./") + "/" + pathToStores +
+ "/" + keyStoreFile;
+ String trustFilename =
+ System.getProperty("test.src", "./") + "/" + pathToStores +
+ "/" + trustStoreFile;
+
+ System.setProperty("javax.net.ssl.keyStore", keyFilename);
+ System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+ System.setProperty("javax.net.ssl.trustStore", trustFilename);
+ System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+ if (debug) {
+ System.setProperty("javax.net.debug", "all");
+ }
+
+ try {
+ hostname = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException uhe) {
+ System.out.println(
+ "Ignore the test as the local hostname cannot be determined");
+
+ return;
+ }
+
+ System.out.println(
+ "The fully qualified domain name of the local host is " +
+ hostname);
+ // Ignore the test if the hostname does not sound like a domain name.
+ if ((hostname == null) || hostname.isEmpty() ||
+ hostname.startsWith("localhost") ||
+ Character.isDigit(hostname.charAt(hostname.length() - 1))) {
+
+ System.out.println("Ignore the test as the local hostname " +
+ "cannot be determined as fully qualified domain name");
+
+ return;
+ }
+
+ /*
+ * Start the tests.
+ */
+ new ImpactOnSNI();
+ }
+
+ private Thread clientThread = null;
+ private Thread serverThread = null;
+
+ /*
+ * Primary constructor, used to drive remainder of the test.
+ *
+ * Fork off the other side, then do your work.
+ */
+ ImpactOnSNI() throws Exception {
+ Exception startException = null;
+ try {
+ if (separateServerThread) {
+ startServer(true);
+ startClient(false);
+ } else {
+ startClient(true);
+ startServer(false);
+ }
+ } catch (Exception e) {
+ startException = e;
+ }
+
+ /*
+ * Wait for other side to close down.
+ */
+ if (separateServerThread) {
+ if (serverThread != null) {
+ serverThread.join();
+ }
+ } else {
+ if (clientThread != null) {
+ clientThread.join();
+ }
+ }
+
+ /*
+ * When we get here, the test is pretty much over.
+ * Which side threw the error?
+ */
+ Exception local;
+ Exception remote;
+
+ if (separateServerThread) {
+ remote = serverException;
+ local = clientException;
+ } else {
+ remote = clientException;
+ local = serverException;
+ }
+
+ Exception exception = null;
+
+ /*
+ * Check various exception conditions.
+ */
+ if ((local != null) && (remote != null)) {
+ // If both failed, return the curthread's exception.
+ local.initCause(remote);
+ exception = local;
+ } else if (local != null) {
+ exception = local;
+ } else if (remote != null) {
+ exception = remote;
+ } else if (startException != null) {
+ exception = startException;
+ }
+
+ /*
+ * If there was an exception *AND* a startException,
+ * output it.
+ */
+ if (exception != null) {
+ if (exception != startException && startException != null) {
+ exception.addSuppressed(startException);
+ }
+ throw exception;
+ }
+
+ // Fall-through: no exception to throw!
+ }
+
+ private void startServer(boolean newThread) throws Exception {
+ if (newThread) {
+ serverThread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ /*
+ * Our server thread just died.
+ *
+ * Release the client, if not active already...
+ */
+ System.err.println("Server died...");
+ serverReady = true;
+ serverException = e;
+ }
+ }
+ };
+ serverThread.start();
+ } else {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ serverException = e;
+ } finally {
+ serverReady = true;
+ }
+ }
+ }
+
+ private void startClient(boolean newThread) throws Exception {
+ if (newThread) {
+ clientThread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ /*
+ * Our client thread just died.
+ */
+ System.err.println("Client died...");
+ clientException = e;
+ }
+ }
+ };
+ clientThread.start();
+ } else {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ clientException = e;
+ }
+ }
+ }
+}

41
8155049-pr3352.patch Normal file
View File

@ -0,0 +1,41 @@
# HG changeset patch
# User rhalade
# Date 1463420211 25200
# Mon May 16 10:36:51 2016 -0700
# Node ID c0e856f2dacdf5eb5cdea380da32ba210aee9579
# Parent fb617df8fbac42e962219e45cbd29b15b5ecdc63
8155049, PR3352: New tests from 8144566 fail with "No expected Server Name Indication"
Reviewed-by: xuelei
diff --git a/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java b/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
--- openjdk/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
+++ openjdk/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
@@ -34,9 +34,6 @@
*/
import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.util.*;
import java.net.*;
import javax.net.ssl.*;
@@ -197,6 +194,7 @@
hostname);
// Ignore the test if the hostname does not sound like a domain name.
if ((hostname == null) || hostname.isEmpty() ||
+ !hostname.contains(".") || hostname.endsWith(".") ||
hostname.startsWith("localhost") ||
Character.isDigit(hostname.charAt(hostname.length() - 1))) {
diff --git a/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java b/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
--- openjdk/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
+++ openjdk/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
@@ -235,6 +235,7 @@
hostname);
// Ignore the test if the hostname does not sound like a domain name.
if ((hostname == null) || hostname.isEmpty() ||
+ !hostname.contains(".") || hostname.endsWith(".") ||
hostname.startsWith("localhost") ||
Character.isDigit(hostname.charAt(hostname.length() - 1))) {

48
8165231-rh1437545.patch Normal file
View File

@ -0,0 +1,48 @@
# HG changeset patch
# User horii
# Date 1473905514 14400
# Wed Sep 14 22:11:54 2016 -0400
# Node ID 8d16f74380a78eb76cb33183a64440316393903e
# Parent be698ac288484ab140715ee29ed9335e6ea8a33b
8165231: java.nio.Bits.unaligned() doesn't return true on ppc
Reviewed-by: simonis, coffeys
diff --git a/src/share/classes/java/nio/Bits.java b/src/share/classes/java/nio/Bits.java
--- openjdk/jdk/src/share/classes/java/nio/Bits.java
+++ openjdk/jdk/src/share/classes/java/nio/Bits.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -614,7 +614,8 @@
String arch = AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("os.arch"));
unaligned = arch.equals("i386") || arch.equals("x86")
- || arch.equals("amd64") || arch.equals("x86_64");
+ || arch.equals("amd64") || arch.equals("x86_64")
+ || arch.equals("ppc64") || arch.equals("ppc64le");
unalignedKnown = true;
return unaligned;
}
diff --git a/src/share/classes/sun/security/provider/ByteArrayAccess.java b/src/share/classes/sun/security/provider/ByteArrayAccess.java
--- openjdk/jdk/src/share/classes/sun/security/provider/ByteArrayAccess.java
+++ openjdk/jdk/src/share/classes/sun/security/provider/ByteArrayAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -94,7 +94,7 @@
String arch = java.security.AccessController.doPrivileged
(new sun.security.action.GetPropertyAction("os.arch", ""));
return arch.equals("i386") || arch.equals("x86") || arch.equals("amd64")
- || arch.equals("x86_64");
+ || arch.equals("x86_64") || arch.equals("ppc64") || arch.equals("ppc64le");
}
/**

View File

@ -1,83 +0,0 @@
# HG changeset patch
# User dholmes
# Date 1483660520 18000
# Thu Jan 05 18:55:20 2017 -0500
# Node ID 652fe741b8f2bfdacba66d772cc89fe7ec6dea66
# Parent 9e43b1c17a3ad5b26d64499c72db61a1dc1649f0
8170888, PR3314: [linux] Experimental support for cgroup memory limits in container (ie Docker) environments
Summary: Set apparent physical memory to cgroup memory limit when UseCGroupMemoryLimitForHeap is true
Reviewed-by: acorn, gtriantafill
Contributed-by: Christine Flood <chf@redhat.com>
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
--- openjdk/hotspot/src/share/vm/runtime/arguments.cpp
+++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -1768,10 +1768,39 @@
FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
}
- const julong phys_mem =
+ julong phys_mem =
FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
: (julong)MaxRAM;
+ // Experimental support for CGroup memory limits
+ if (UseCGroupMemoryLimitForHeap) {
+ // This is a rough indicator that a CGroup limit may be in force
+ // for this process
+ const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
+ FILE *fp = fopen(lim_file, "r");
+ if (fp != NULL) {
+ julong cgroup_max = 0;
+ int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
+ if (ret == 1 && cgroup_max > 0) {
+ // If unlimited, cgroup_max will be a very large, but unspecified
+ // value, so use initial phys_mem as a limit
+ if (PrintGCDetails && Verbose) {
+ // Cannot use gclog_or_tty yet.
+ tty->print_cr("Setting phys_mem to the min of cgroup limit ("
+ JULONG_FORMAT "MB) and initial phys_mem ("
+ JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
+ }
+ phys_mem = MIN2(cgroup_max, phys_mem);
+ } else {
+ warning("Unable to read/parse cgroup memory limit from %s: %s",
+ lim_file, errno != 0 ? strerror(errno) : "unknown error");
+ }
+ fclose(fp);
+ } else {
+ warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
+ }
+ }
+
// If the maximum heap size has not been set with -Xmx,
// then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap.
diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
--- openjdk/hotspot/src/share/vm/runtime/globals.hpp
+++ openjdk/hotspot/src/share/vm/runtime/globals.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -2080,6 +2080,10 @@
"Maximum ergonomically set heap size (in bytes); zero means use " \
"MaxRAM / MaxRAMFraction") \
\
+ experimental(bool, UseCGroupMemoryLimitForHeap, false, \
+ "Use CGroup memory limit as physical memory limit for heap " \
+ "sizing") \
+ \
product(uintx, MaxRAMFraction, 4, \
"Maximum fraction (1/n) of real memory used for maximum heap " \
"size") \

77
8173941-pr3326.patch Normal file
View File

@ -0,0 +1,77 @@
# HG changeset patch
# User ysuenaga
# Date 1487123491 18000
# Tue Feb 14 20:51:31 2017 -0500
# Node ID 15922b2f31db4857ec84efdf533c41b19e68030b
# Parent 652fe741b8f2bfdacba66d772cc89fe7ec6dea66
8173941, PR3326: SA does not work if executable is DSO
Reviewed-by: aph, dsamersoff
diff --git a/agent/src/os/linux/elfmacros.h b/agent/src/os/linux/elfmacros.h
--- openjdk/hotspot/agent/src/os/linux/elfmacros.h
+++ openjdk/hotspot/agent/src/os/linux/elfmacros.h
@@ -33,6 +33,7 @@
#define ELF_NHDR Elf64_Nhdr
#define ELF_DYN Elf64_Dyn
#define ELF_ADDR Elf64_Addr
+#define ELF_AUXV Elf64_auxv_t
#define ELF_ST_TYPE ELF64_ST_TYPE
@@ -45,6 +46,7 @@
#define ELF_NHDR Elf32_Nhdr
#define ELF_DYN Elf32_Dyn
#define ELF_ADDR Elf32_Addr
+#define ELF_AUXV Elf32_auxv_t
#define ELF_ST_TYPE ELF32_ST_TYPE
diff --git a/agent/src/os/linux/ps_core.c b/agent/src/os/linux/ps_core.c
--- openjdk/hotspot/agent/src/os/linux/ps_core.c
+++ openjdk/hotspot/agent/src/os/linux/ps_core.c
@@ -642,6 +642,18 @@
if (core_handle_prstatus(ph, descdata, notep->n_descsz) != true) {
return false;
}
+ } else if (notep->n_type == NT_AUXV) {
+ // Get first segment from entry point
+ ELF_AUXV *auxv = (ELF_AUXV *)descdata;
+ while (auxv->a_type != AT_NULL) {
+ if (auxv->a_type == AT_ENTRY) {
+ // Set entry point address to address of dynamic section.
+ // We will adjust it in read_exec_segments().
+ ph->core->dynamic_addr = auxv->a_un.a_val;
+ break;
+ }
+ auxv++;
+ }
}
p = descdata + ROUNDUP(notep->n_descsz, 4);
}
@@ -826,7 +838,13 @@
// from PT_DYNAMIC we want to read address of first link_map addr
case PT_DYNAMIC: {
- ph->core->dynamic_addr = exec_php->p_vaddr;
+ if (exec_ehdr->e_type == ET_EXEC) {
+ ph->core->dynamic_addr = exec_php->p_vaddr;
+ } else { // ET_DYN
+ // dynamic_addr has entry point of executable.
+ // Thus we should substract it.
+ ph->core->dynamic_addr += exec_php->p_vaddr - exec_ehdr->e_entry;
+ }
print_debug("address of _DYNAMIC is 0x%lx\n", ph->core->dynamic_addr);
break;
}
@@ -1024,8 +1042,9 @@
goto err;
}
- if (read_elf_header(ph->core->exec_fd, &exec_ehdr) != true || exec_ehdr.e_type != ET_EXEC) {
- print_debug("executable file is not a valid ELF ET_EXEC file\n");
+ if (read_elf_header(ph->core->exec_fd, &exec_ehdr) != true ||
+ ((exec_ehdr.e_type != ET_EXEC) && (exec_ehdr.e_type != ET_DYN))) {
+ print_debug("executable file is not a valid ELF file\n");
goto err;
}

View File

@ -1,16 +1,16 @@
# HG changeset patch
# User roland
# Date 1487208397 28800
# Node ID 35db0413819a18edd6718dd42e7536182c42aa8b
# Parent ac559f3ccca81de373f18ac7c4b2d813d0278920
8174164: SafePointNode::_replaced_nodes breaks with irreducible loops
# Wed Feb 15 17:26:37 2017 -0800
# Node ID a9cbaff50d3d7e3a1d2dbdc0121c470142b87270
# Parent 15922b2f31db4857ec84efdf533c41b19e68030b
8174164, PR3334, RH1417266: SafePointNode::_replaced_nodes breaks with irreducible loops
Reviewed-by: kvn
diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/callnode.hpp
--- openjdk/hotspot/src/share/vm/opto/callnode.hpp Wed Feb 15 11:14:45 2017 +0100
+++ openjdk/hotspot/src/share/vm/opto/callnode.hpp Wed Feb 15 17:26:37 2017 -0800
@@ -452,8 +452,8 @@
diff --git a/src/share/vm/opto/callnode.hpp b/src/share/vm/opto/callnode.hpp
--- openjdk/hotspot/src/share/vm/opto/callnode.hpp
+++ openjdk/hotspot/src/share/vm/opto/callnode.hpp
@@ -449,8 +449,8 @@
void delete_replaced_nodes() {
_replaced_nodes.reset();
}
@ -21,60 +21,10 @@ diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/callnode.hpp
}
void merge_replaced_nodes_with(SafePointNode* sfpt) {
_replaced_nodes.merge_with(sfpt->_replaced_nodes);
# I was informed that this hunk is not necessary in jdk8
#diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/library_call.cpp
#--- openjdk/hotspot/src/share/vm/opto/library_call.cpp Wed Feb 15 11:14:45 2017 +0100
#+++ openjdk/hotspot/src/share/vm/opto/library_call.cpp Wed Feb 15 17:26:37 2017 -0800
#@@ -277,7 +277,8 @@
# AllocateArrayNode* tightly_coupled_allocation(Node* ptr,
# RegionNode* slow_region);
# JVMState* arraycopy_restore_alloc_state(AllocateArrayNode* alloc, int& saved_reexecute_sp);
#- void arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp);
#+ void arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp,
#+ uint new_idx);
#
# typedef enum { LS_get_add, LS_get_set, LS_cmp_swap, LS_cmp_swap_weak, LS_cmp_exchange } LoadStoreKind;
# MemNode::MemOrd access_kind_to_memord_LS(AccessKind access_kind, bool is_store);
#@@ -4882,7 +4883,8 @@
# // deoptimize. This is possible because tightly_coupled_allocation()
# // guarantees there's no observer of the allocated array at this point
# // and the control flow is simple enough.
#-void LibraryCallKit::arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp) {
#+void LibraryCallKit::arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms,
#+ int saved_reexecute_sp, uint new_idx) {
# if (saved_jvms != NULL && !stopped()) {
# assert(alloc != NULL, "only with a tightly coupled allocation");
# // restore JVM state to the state at the arraycopy
#@@ -4891,7 +4893,7 @@
# assert(saved_jvms->map()->i_o() == map()->i_o(), "IO state changed?");
# // If we've improved the types of some nodes (null check) while
# // emitting the guards, propagate them to the current state
#- map()->replaced_nodes().apply(saved_jvms->map());
#+ map()->replaced_nodes().apply(saved_jvms->map(), new_idx);
# set_jvms(saved_jvms);
# _reexecute_sp = saved_reexecute_sp;
#
#@@ -4949,6 +4951,7 @@
# Node* dest_offset = argument(3); // type: int
# Node* length = argument(4); // type: int
#
#+ uint new_idx = C->unique();
#
# // Check for allocation before we add nodes that would confuse
# // tightly_coupled_allocation()
#@@ -5164,7 +5167,7 @@
# }
# }
#
#- arraycopy_move_allocation_here(alloc, dest, saved_jvms, saved_reexecute_sp);
#+ arraycopy_move_allocation_here(alloc, dest, saved_jvms, saved_reexecute_sp, new_idx);
#
# if (stopped()) {
# return true;
diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/parse1.cpp
--- openjdk/hotspot/src/share/vm/opto/parse1.cpp Wed Feb 15 11:14:45 2017 +0100
+++ openjdk/hotspot/src/share/vm/opto/parse1.cpp Wed Feb 15 17:26:37 2017 -0800
@@ -1086,7 +1086,7 @@
diff --git a/src/share/vm/opto/parse1.cpp b/src/share/vm/opto/parse1.cpp
--- openjdk/hotspot/src/share/vm/opto/parse1.cpp
+++ openjdk/hotspot/src/share/vm/opto/parse1.cpp
@@ -1048,7 +1048,7 @@
kit.make_dtrace_method_exit(method());
}
if (_replaced_nodes_for_exceptions) {
@ -83,7 +33,7 @@ diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/parse1.cpp
}
// Done with exception-path processing.
ex_map = kit.make_exception_state(ex_oop);
@@ -1107,7 +1107,7 @@
@@ -1069,7 +1069,7 @@
_exits.add_exception_state(ex_map);
}
}
@ -92,10 +42,10 @@ diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/parse1.cpp
}
//-----------------------------create_entry_map-------------------------------
diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/replacednodes.cpp
--- openjdk/hotspot/src/share/vm/opto/replacednodes.cpp Wed Feb 15 11:14:45 2017 +0100
+++ openjdk/hotspot/src/share/vm/opto/replacednodes.cpp Wed Feb 15 17:26:37 2017 -0800
@@ -92,13 +92,17 @@
diff --git a/src/share/vm/opto/replacednodes.cpp b/src/share/vm/opto/replacednodes.cpp
--- openjdk/hotspot/src/share/vm/opto/replacednodes.cpp
+++ openjdk/hotspot/src/share/vm/opto/replacednodes.cpp
@@ -91,13 +91,17 @@
}
// Perfom node replacement (used when returning to caller)
@ -115,9 +65,9 @@ diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/replacednodes.cpp
}
}
diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/replacednodes.hpp
--- openjdk/hotspot/src/share/vm/opto/replacednodes.hpp Wed Feb 15 11:14:45 2017 +0100
+++ openjdk/hotspot/src/share/vm/opto/replacednodes.hpp Wed Feb 15 17:26:37 2017 -0800
diff --git a/src/share/vm/opto/replacednodes.hpp b/src/share/vm/opto/replacednodes.hpp
--- openjdk/hotspot/src/share/vm/opto/replacednodes.hpp
+++ openjdk/hotspot/src/share/vm/opto/replacednodes.hpp
@@ -71,7 +71,7 @@
void record(Node* initial, Node* improved);
void transfer_from(const ReplacedNodes& other, uint idx);
@ -127,4 +77,3 @@ diff -r ac559f3ccca8 -r 35db0413819a src/share/vm/opto/replacednodes.hpp
void merge_with(const ReplacedNodes& other);
bool is_empty() const;
void dump(outputStream *st) const;

View File

@ -0,0 +1,122 @@
# HG changeset patch
# User adinn
# Date 1487931564 0
# Fri Feb 24 10:19:24 2017 +0000
# Node ID d41592af9af3790fe5eee30ce686d85cff09c942
# Parent 1ac9b0f1bf17fc5935bfa8250550eabc2ffb6785
8174729, PR3336, RH1420518: Race Condition in java.lang.reflect.WeakCache
Summary: Race can occur between Proxy.getProxyClass and Proxy.isProxyClass
Reviewed-by: mchung
diff --git a/src/share/classes/java/lang/reflect/WeakCache.java b/src/share/classes/java/lang/reflect/WeakCache.java
--- openjdk/jdk/src/share/classes/java/lang/reflect/WeakCache.java
+++ openjdk/jdk/src/share/classes/java/lang/reflect/WeakCache.java
@@ -239,11 +239,11 @@
// wrap value with CacheValue (WeakReference)
CacheValue<V> cacheValue = new CacheValue<>(value);
+ // put into reverseMap
+ reverseMap.put(cacheValue, Boolean.TRUE);
+
// try replacing us with CacheValue (this should always succeed)
- if (valuesMap.replace(subKey, this, cacheValue)) {
- // put also in reverseMap
- reverseMap.put(cacheValue, Boolean.TRUE);
- } else {
+ if (!valuesMap.replace(subKey, this, cacheValue)) {
throw new AssertionError("Should not reach here");
}
diff --git a/test/java/lang/reflect/Proxy/ProxyRace.java b/test/java/lang/reflect/Proxy/ProxyRace.java
new file mode 100644
--- /dev/null
+++ openjdk/jdk/test/java/lang/reflect/Proxy/ProxyRace.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+
+import java.lang.reflect.Proxy;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Phaser;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @test
+ * @bug 8174729
+ * @summary Proxy.getProxyClass() / Proxy.isProxyClass() race detector
+ * @run main ProxyRace
+ * @author plevart
+ */
+
+public class ProxyRace {
+
+ static final int threads = 8;
+
+ static volatile ClassLoader classLoader;
+ static volatile boolean terminate;
+ static final AtomicInteger racesDetected = new AtomicInteger();
+
+ public static void main(String[] args) throws Exception {
+
+ Phaser phaser = new Phaser(threads) {
+ @Override
+ protected boolean onAdvance(int phase, int registeredParties) {
+ // install new ClassLoader on each advance
+ classLoader = new CL();
+ return terminate;
+ }
+ };
+
+ ExecutorService exe = Executors.newFixedThreadPool(threads);
+
+ for (int i = 0; i < threads; i++) {
+ exe.execute(() -> {
+ while (phaser.arriveAndAwaitAdvance() >= 0) {
+ Class<?> proxyClass = Proxy.getProxyClass(classLoader, Runnable.class);
+ if (!Proxy.isProxyClass(proxyClass)) {
+ racesDetected.incrementAndGet();
+ }
+ }
+ });
+ }
+
+ Thread.sleep(5000L);
+
+ terminate = true;
+ exe.shutdown();
+ exe.awaitTermination(5L, TimeUnit.SECONDS);
+
+ System.out.println(racesDetected.get() + " races detected");
+ if (racesDetected.get() != 0) {
+ throw new RuntimeException(racesDetected.get() + " races detected");
+ }
+ }
+
+ static class CL extends ClassLoader {
+ public CL() {
+ super(ClassLoader.getSystemClassLoader());
+ }
+ }
+}

View File

@ -0,0 +1,100 @@
# HG changeset patch
# User roland
# Date 1487286884 28800
# Thu Feb 16 15:14:44 2017 -0800
# Node ID 1b4eb44fbfcd0fceb485d89d91eb893d99f5864b
# Parent a9cbaff50d3d7e3a1d2dbdc0121c470142b87270
8175097, PR3334, RH1417266: [TESTBUG] 8174164 fix missed the test
Reviewed-by: kvn
diff --git a/test/compiler/c2/TestReplacedNodesOSR.java b/test/compiler/c2/TestReplacedNodesOSR.java
new file mode 100644
--- /dev/null
+++ openjdk/hotspot/test/compiler/c2/TestReplacedNodesOSR.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017, Red Hat, Inc. 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 8174164
+ * @summary SafePointNode::_replaced_nodes breaks with irreducible loops
+ * @run main/othervm -XX:-BackgroundCompilation TestReplacedNodesOSR
+ *
+ */
+
+public class TestReplacedNodesOSR {
+
+ static Object dummy;
+
+ static interface I {
+ }
+
+ static class A implements I {
+ }
+
+ static final class MyException extends Exception {
+ }
+
+ static final A obj = new A();
+ static I static_field() { return obj; }
+
+ // When OSR compiled, this method has an irreducible loop
+ static void test(int v, MyException e) {
+ int i = 0;
+ for (;;) {
+ if (i == 1000) {
+ break;
+ }
+ try {
+ if ((i%2) == 0) {
+ int j = 0;
+ for (;;) {
+ j++;
+ if (i+j != v) {
+ if (j == 1000) {
+ break;
+ }
+ } else {
+ A a = (A)static_field();
+ // replaced node recorded here
+ throw e;
+ }
+ }
+ }
+ } catch(MyException ex) {
+ }
+ i++;
+ // replaced node applied on return of the method
+ // replaced node used here
+ dummy = static_field();
+ }
+ }
+
+
+ static public void main(String[] args) {
+ for (int i = 0; i < 1000; i++) {
+ test(1100, new MyException());
+ }
+ }
+}

View File

@ -131,6 +131,7 @@ else
patch -Np1 < $PR2126
fi;
fi
find . -name '*.orig' -exec rm -vf '{}' ';'
popd
echo "Compressing remaining forest"

View File

@ -34,7 +34,7 @@
%global include_debug_build 0
%endif
# on intels, we build shenandoah htspot
# On x86_64 and AArch64, we use the Shenandoah HotSpot
%ifarch x86_64 %{aarch64}
%global use_shenandoah_hotspot 1
%else
@ -108,50 +108,64 @@
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$
# In some cases, the arch used by the JDK does
# not match _arch.
# Also, in some cases, the machine name used by SystemTap
# does not match that given by _build_cpu
%ifarch x86_64
%global archinstall amd64
%global stapinstall x86_64
%endif
%ifarch ppc
%global archinstall ppc
%global stapinstall powerpc
%endif
%ifarch %{ppc64be}
%global archinstall ppc64
%global stapinstall powerpc
%endif
%ifarch %{ppc64le}
%global archinstall ppc64le
%global stapinstall powerpc
%endif
%ifarch %{ix86}
%global archinstall i386
%global stapinstall i386
%endif
%ifarch ia64
%global archinstall ia64
%global stapinstall ia64
%endif
%ifarch s390
%global archinstall s390
%global stapinstall s390
%endif
%ifarch s390x
%global archinstall s390x
%global stapinstall s390
%endif
%ifarch %{arm}
%global archinstall arm
%global stapinstall arm
%endif
%ifarch %{aarch64}
%global archinstall aarch64
%global stapinstall arm64
%endif
# 32 bit sparc, optimized for v9
%ifarch sparcv9
%global archinstall sparc
%global stapinstall %{_build_cpu}
%endif
# 64 bit sparc
%ifarch sparc64
%global archinstall sparcv9
%global stapinstall %{_build_cpu}
%endif
%ifnarch %{jit_arches}
%global archinstall %{_arch}
%endif
%ifarch %{jit_arches}
%global with_systemtap 1
%else
@ -214,7 +228,7 @@
# for the primary arch for now). Systemtap uses the machine name
# aka build_cpu as architecture specific directory name.
%global tapsetroot /usr/share/systemtap
%global tapsetdir %{tapsetroot}/tapset/%{_build_cpu}
%global tapsetdir %{tapsetroot}/tapset/%{stapinstall}
%endif
# not-duplicated scriplets for normal/debug packages
@ -799,7 +813,7 @@ URL: http://openjdk.java.net/
# aarch64-port now contains integration forest of both aarch64 and normal jdk
# Source from upstream OpenJDK8 project. To regenerate, use
# VERSION=aarch64-jdk8u121-b14 FILE_NAME_ROOT=aarch64-port-jdk8u-${VERSION}
# VERSION=%%{revision} FILE_NAME_ROOT=%%{project}-%%{repo}-${VERSION}
# REPO_ROOT=<path to checked-out repository> generate_source_tarball.sh
# where the source is obtained from http://hg.openjdk.java.net/%%{project}/%%{repo}
Source0: %{project}-%{repo}-%{revision}.tar.xz
@ -811,14 +825,14 @@ Source2: README.src
# They are based on code contained in the IcedTea7 project.
# Systemtap tapsets. Zipped up to keep it small.
Source8: systemtap-tapset-3.1.0.tar.xz
Source8: systemtap-tapset-3.4.0pre01.tar.xz
# Desktop files. Adapated from IcedTea.
Source9: jconsole.desktop.in
Source10: policytool.desktop.in
# nss configuration file
Source11: nss.cfg
Source11: nss.cfg.in
# Removed libraries that we link instead
Source12: %{name}-remove-intree-libraries.sh
@ -910,20 +924,32 @@ Patch507: pr2842-02.patch
Patch400: 8154313.patch
# S6260348, PR3066: GTK+ L&F JTextComponent not respecting desktop caret blink rate
Patch526: 6260348-pr3066.patch
# S8162384, PR3122, RH1358661: Performance regression: bimorphic inlining may be bypassed by type speculation
Patch532: 8162384-pr3122-rh1358661.patch
# 8174164, PR3334, RH1417266: SafePointNode::_replaced_nodes breaks with irreducible loops"
Patch537: 8174164-pr3334-rh1417266.patch
# 8061305, PR3335, RH1423421: Javadoc crashes when method name ends with "Property"
Patch538: 8061305-pr3335-rh1423421.patch
# Patches upstream and appearing in 8u131
# 8170888, PR3314, RH1390708: [linux] Experimental support for cgroup memory limits in container (ie Docker) environments
Patch536: 8170888-pr3314-rh1390708.patch
# 6515172, PR3346: Runtime.availableProcessors() ignores Linux taskset command
Patch542: 6515172-pr3346.patch
# Patches upstream and appearing in 8u152
# 8153711, PR3313, RH1284948: [REDO] JDWP: Memory Leak: GlobalRefs never deleted when processing invokeMethod command
Patch535: 8153711-pr3313-rh1284948.patch
# 8144566, PR3352: Custom HostnameVerifier disables SNI extension
Patch544: 8144566-pr3352.patch
# 8155049, PR3352: New tests from 8144566 fail with "No expected Server Name Indication"
Patch545: 8155049-pr3352.patch
# 8162384, PR3122, RH1358661: Performance regression: bimorphic inlining may be bypassed by type speculation
Patch532: 8162384-pr3122-rh1358661.patch
# 8165231, RH1437545: java.nio.Bits.unaligned() doesn't return true on ppc
Patch546: 8165231-rh1437545.patch
# 8173941, PR3326: SA does not work if executable is DSO
Patch547: 8173941-pr3326.patch
# 8174164, PR3334, RH1417266: SafePointNode::_replaced_nodes breaks with irreducible loops"
Patch537: 8174164-pr3334-rh1417266.patch
# 8174729, PR3336, RH1420518: Race Condition in java.lang.reflect.WeakCache
Patch548: 8174729-pr3336-rh1420518.patch
# 8175097, PR3334, RH1417266: [TESTBUG] 8174164 fix missed the test
Patch549: 8175097-pr3334-rh1417266.patch
# Patches ineligible for 8u
# 8043805: Allow using a system-installed libjpeg
@ -1207,11 +1233,12 @@ fi
# For old patches
ln -s openjdk jdk8
%if %{use_shenandoah_hotspot}
#on intels, repalce hotpost by shenandoah-able hotspot
# On Shenandoah-supported architectures, replace HotSpot with
# the Shenandoah version
pushd openjdk
tar -xf %{SOURCE999}
rm -rf hotspot
cp -r openjdk/hotspot .
mv openjdk/hotspot .
rm -rf openjdk
popd
%endif
@ -1230,9 +1257,12 @@ cp %{SOURCE101} openjdk/common/autoconf/build-aux/
# Remove libraries that are linked
sh %{SOURCE12}
# System library fixes
%patch201
%patch202
%patch203
# Debugging fixes
%patch204
%patch205
%patch206
@ -1250,12 +1280,13 @@ sh %{SOURCE12}
# ppc64le fixes
# Zero fixes.
%patch603
%patch601
%patch602
# Zero fixes.
# Upstreamable fixes
%patch502
%patch504
%patch506
@ -1272,15 +1303,23 @@ sh %{SOURCE12}
%patch518
%patch400
%patch523
%patch525
%patch526
%patch528
%patch532
%patch533
%patch535
%patch536
%patch537
%patch538
%patch542
%patch544
%patch545
%patch546
%patch547
%patch548
%patch549
# RPM-only fixes
%patch525
%patch533
%patch539
# RHEL-only patches
@ -1327,6 +1366,9 @@ for file in %{SOURCE9} %{SOURCE10} ; do
done
done
# Setup nss.cfg
sed -e s:@NSS_LIBDIR@:%{NSS_LIBDIR}:g %{SOURCE11} > nss.cfg
%build
# How many cpu's do we have?
@ -1430,7 +1472,7 @@ popd >& /dev/null
export JAVA_HOME=$(pwd)/%{buildoutputdir $suffix}/images/%{j2sdkimage}
# Install nss.cfg right away as we will be using the JRE above
install -m 644 %{SOURCE11} $JAVA_HOME/jre/lib/security/
install -m 644 nss.cfg $JAVA_HOME/jre/lib/security/
# Use system-wide tzdata
rm $JAVA_HOME/jre/lib/tzdb.dat

View File

View File

@ -1,8 +1,8 @@
diff --git a/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java b/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
--- openjdk/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
+++ openjdk/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
@@ -160,20 +160,10 @@
}
@@ -168,20 +168,10 @@
"contains no supported elliptic curves");
}
} else { // default curves
- int[] ids;