JDK-8021771 : warning: stat64 is deprecated - when building on OSX 10.7.5
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: hs25
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-07-29
  • Updated: 2014-05-12
  • Resolved: 2013-08-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u60Fixed 8Fixed hs25Fixed
Related Reports
Relates :  
Description
Kris Mok reports:

I'm building a freshly cloned repo from the tip of hotspot-comp on Mac OS X
10.7.5, and got and error:

llvm-g++ -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64 -DASSERT -I.
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/share/vm/prims
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/share/vm
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/share/vm/precompiled
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/cpu/x86/vm
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os_cpu/bsd_x86/vm
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/bsd/vm
-I/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/posix/vm
-I../generated -DHOTSPOT_RELEASE_VERSION="\"25.0-b44-internal\""
-DHOTSPOT_BUILD_TARGET="\"fastdebug\""
-DHOTSPOT_BUILD_USER="\"rednaxelafx\"" -DHOTSPOT_LIB_ARCH=\"amd64\"
-DHOTSPOT_VM_DISTRO="\"OpenJDK\""  -DTARGET_OS_FAMILY_bsd -DTARGET_ARCH_x86
-DTARGET_ARCH_MODEL_x86_64 -DTARGET_OS_ARCH_bsd_x86
-DTARGET_OS_ARCH_MODEL_bsd_x86_64 -DTARGET_COMPILER_gcc -DCOMPILER2
-DCOMPILER1 -fPIC -fno-rtti -fno-exceptions -pthread -fcheck-new -m64
 -pipe -fno-strict-aliasing -DMAC_OS_X_VERSION_MAX_ALLOWED=1070
-mmacosx-version-min=10.7.0 -Os  -DVM_LITTLE_ENDIAN -D_LP64=1
-fno-omit-frame-pointer -Werror -Wunused-function    -DDTRACE_ENABLED
 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -DALLOW_OPERATOR_NEW_USAGE -c -MMD -MP
-MF ../generated/dependencies/attachListener_bsd.o.d -fpch-deps -o
attachListener_bsd.o
/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
cc1plus: warnings being treated as errors
/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:
In static member function ���static void AttachListener::vm_start()���:
/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455:
warning: ���stat64��� is deprecated (declared at /usr/include/sys/stat.h:466)
/Users/rednaxelafx/build/hotspot-comp/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455:
warning: ���stat64��� is deprecated (declared at /usr/include/sys/stat.h:466)
make[6]: *** [attachListener_bsd.o] Error 1

The problem came from a recent commit [1]:
7162400: Intermittent java.io.IOException: Bad file number during
HotSpotVirtualMachine.executeCommand

According to [2], the *-64 variants of the stat*() functions have been
deprecated on Mac OS X and should be avoided.

The fix is simple:
diff -r d90d1b96b65b src/os/bsd/vm/attachListener_bsd.cpp
--- a/src/os/bsd/vm/attachListener_bsd.cpp Fri Jul 26 12:37:39 2013 -0700
+++ b/src/os/bsd/vm/attachListener_bsd.cpp Sun Jul 28 15:55:54 2013 +0800
@@ -445,14 +445,14 @@

 void AttachListener::vm_start() {
   char fn[UNIX_PATH_MAX];
-  struct stat64 st;
+  struct stat st;
   int ret;

   int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
            os::get_temp_directory(), os::current_process_id());
   assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");

-  RESTARTABLE(::stat64(fn, &st), ret);
+  RESTARTABLE(::stat(fn, &st), ret);
   if (ret == 0) {
     ret = ::unlink(fn);
     if (ret == -1) {

I'm not sure if this should be done for all BSD platforms. Could anybody
help confirm this?

Thanks,
Kris

(P.S. recovering from bad health...)

[1]: http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/2e8f19c2feef
[2]:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat64.2.html
Comments
All *BSD used to live without stat64.
06-08-2013

Impact High - build failure, can't continue Likelihood Medium - many dev engineers are now hitting this on their OSX systems Workaround medium - requires patching source files directly HMM => P2
05-08-2013

No warning is seen when building on OSX 10.7 so this seems likely to be a new warning. As we will be moving to builds on 10.8 very soon this issue will need to be addressed.
29-07-2013

Kris adds: By the way, my build environment that had this problem was: Mac OS X 10.7.5, XCode 4.1 i686-apple-darwin11-llvm-g++-4.2
29-07-2013