United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8021771 warning: stat64 is deprecated - when building on OSX 10.7.5
JDK-8021771 : warning: stat64 is deprecated - when building on OSX 10.7.5

Details
Type:
Bug
Submit Date:
2013-07-29
Status:
Closed
Updated Date:
2014-01-14
Project Name:
JDK
Resolved Date:
2013-08-07
Component:
hotspot
OS:
os_x
Sub-Component:
svc
CPU:
Priority:
P2
Resolution:
Fixed
Affected Versions:
hs25
Fixed Versions:
hs25 (b46)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

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
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
                                     
2013-08-05
All *BSD used to live without stat64.
                                     
2013-08-06
URL:   http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/195ff07bc7f6
User:  dsamersoff
Date:  2013-08-07 17:24:16 +0000

                                     
2013-08-07
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.
                                     
2013-07-29
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
                                     
2013-07-29
URL:   http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/195ff07bc7f6
User:  amurillo
Date:  2013-08-16 14:58:16 +0000

                                     
2013-08-16



Hardware and Software, Engineered to Work Together