7010192: InetAddress.isReachable hits ShouldNotReachHere with hs20-b04 (win)

Alan Bateman Alan.Bateman at oracle.com
Tue Jan 4 07:08:58 PST 2011


jdk7-b123 has hs20-b04 and so has the changes to 6348631 to remove the 
dependency on the HPI library. One causality is that 
InetAddress.isReachable now crashes the VM on Windows as it hits a 
ShouldNotReachHere guarantee. This is because isReachable is using 
JVM_GetSockOpt which ends up calling the unimplemented os::get_sock_opt. 
On Windows there is no need to use the JVM_* networking functions so the 
simplest fix is to change this code to use getsockopt directly (I've 
deliberately avoiding calling NET_GetSockOpt because this is IPv4 or 
IPv6 specific code). The proposed patch is attached.

-Alan


diff -r 3254c3ae63fe src/windows/native/java/net/Inet4AddressImpl.c
--- a/src/windows/native/java/net/Inet4AddressImpl.c    Mon Dec 27 
11:39:59 2010 -0800
+++ b/src/windows/native/java/net/Inet4AddressImpl.c    Tue Jan 04 
14:59:48 2011 +0000
@@ -559,8 +559,8 @@ Java_java_net_Inet4AddressImpl_isReachab
 
         if (timeout >= 0) {
           optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = WSAGetLastError();
           }
 
diff -r 3254c3ae63fe src/windows/native/java/net/Inet6AddressImpl.c
--- a/src/windows/native/java/net/Inet6AddressImpl.c    Mon Dec 27 
11:39:59 2010 -0800
+++ b/src/windows/native/java/net/Inet6AddressImpl.c    Tue Jan 04 
14:59:48 2011 +0000
@@ -671,8 +671,8 @@ Java_java_net_Inet6AddressImpl_isReachab
         if (timeout >= 0) {
           /* has connection been established? */
           optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = WSAGetLastError();
           }




More information about the net-dev mailing list