United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7091417 recvfrom's 6th input should be of type socklen_t
JDK-7091417 : recvfrom's 6th input should be of type socklen_t

Details
Type:
Bug
Submit Date:
2011-09-16
Status:
Closed
Updated Date:
2012-03-29
Project Name:
JDK
Resolved Date:
2012-03-29
Component:
hotspot
OS:
solaris_11
Sub-Component:
runtime
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u2
Fixed Versions:
hs23 (b09)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
The current JVM doesn't build under Solaris 11 since recvfrom method's 6th input should be a socklen_t.  Diffs are attached.

                                    

Comments
EVALUATION

Ok.
                                     
2011-09-23
SUGGESTED FIX

From ###@###.###:

diff -r 35c656d0b685 src/os/linux/vm/jvm_linux.h
--- a/src/os/linux/vm/jvm_linux.h	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/os/linux/vm/jvm_linux.h	Fri Sep 16 08:41:24 2011 -0500
@@ -73,6 +73,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
 #include <fcntl.h>
 #include <errno.h>
 
diff -r 35c656d0b685 src/os/linux/vm/os_linux.inline.hpp
--- a/src/os/linux/vm/os_linux.inline.hpp	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/os/linux/vm/os_linux.inline.hpp	Fri Sep 16 08:41:24 2011 -0500
@@ -266,7 +266,7 @@
 }
 
 inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
-                         sockaddr *from, int *fromlen) {
+                         sockaddr *from, socklen_t *fromlen) {
   RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
 }
 
diff -r 35c656d0b685 src/os/solaris/vm/jvm_solaris.h
--- a/src/os/solaris/vm/jvm_solaris.h	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/os/solaris/vm/jvm_solaris.h	Fri Sep 16 08:41:24 2011 -0500
@@ -70,6 +70,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
 #include <fcntl.h>
 #include <errno.h>
 
diff -r 35c656d0b685 src/os/solaris/vm/os_solaris.cpp
--- a/src/os/solaris/vm/os_solaris.cpp	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/os/solaris/vm/os_solaris.cpp	Fri Sep 16 08:41:24 2011 -0500
@@ -6429,7 +6429,7 @@
  }
 
 int os::recvfrom(int fd, char *buf, int nBytes, int flags,
-                             sockaddr *from, int *fromlen) {
+                             sockaddr *from, socklen_t *fromlen) {
    //%%note jvm_r11
   INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes,\
     flags, from, fromlen), os::Solaris::clear_interrupted);
diff -r 35c656d0b685 src/share/vm/prims/jvm.cpp
--- a/src/share/vm/prims/jvm.cpp	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/share/vm/prims/jvm.cpp	Fri Sep 16 08:41:24 2011 -0500
@@ -3523,7 +3523,7 @@
 JVM_END
 
 
-JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen))
+JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, socklen_t *fromlen))
   JVMWrapper2("JVM_RecvFrom (0x%x)", fd);
   //%note jvm_r6
   return os::recvfrom(fd, buf, nBytes, flags, from, fromlen);
diff -r 35c656d0b685 src/share/vm/prims/jvm.h
--- a/src/share/vm/prims/jvm.h	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/share/vm/prims/jvm.h	Fri Sep 16 08:41:24 2011 -0500
@@ -1376,7 +1376,7 @@
 
 JNIEXPORT jint JNICALL
 JVM_RecvFrom(jint fd, char *buf, int nBytes,
-                  int flags, struct sockaddr *from, int *fromlen);
+                  int flags, struct sockaddr *from, socklen_t *fromlen);
 
 JNIEXPORT jint JNICALL
 JVM_SendTo(jint fd, char *buf, int len,
diff -r 35c656d0b685 src/share/vm/runtime/os.hpp
--- a/src/share/vm/runtime/os.hpp	Wed Sep 14 13:57:32 2011 -0700
+++ b/src/share/vm/runtime/os.hpp	Fri Sep 16 08:41:24 2011 -0500
@@ -587,7 +587,7 @@
   static int bind(int fd, struct sockaddr *him, int len);
   static int accept(int fd, struct sockaddr *him, int *len);
   static int recvfrom(int fd, char *buf, int nbytes, int flags,
-                             struct sockaddr *from, int *fromlen);
+                             struct sockaddr *from, socklen_t *fromlen);
   static int get_sock_name(int fd, struct sockaddr *him, int *len);
   static int sendto(int fd, char *buf, int len, int flags,
                            struct sockaddr *to, int tolen);
                                     
2011-09-23
EVALUATION

The attached suggested fix doesn't cover enough ground.  In addition to recvfrom
and sendto, the interfaces to recv, send, connect, accept, getsockname, getsockopt,
and setsockopt should also be fixed to use either socklen_t*, socklen_t or size_t.

This is also a correctness issue, as on some systems socklen_t isn't the same
width as int.
                                     
2011-12-20
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/11c26bfcf8c7
                                     
2011-12-22
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/11c26bfcf8c7
                                     
2012-03-22



Hardware and Software, Engineered to Work Together