JDK-6369565 : JVM is crashing when it is not able to determine current working directory
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris
  • CPU: sparc
  • Submitted: 2006-01-06
  • Updated: 2010-08-06
  • Resolved: 2006-03-10
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 6
6Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
JVM will crash, if it is not able to determine the current working directory.

Please see the following  results with build 59c and with the build 63
<Result-b59c>
bash-3.00$ pwd
/home/rg157576/vittal
bash-3.00$ /net/sqindia.india/export/disk09/jdk/1.6.0/b59c//binaries/solsparc/bin/java -version
Error occurred during initialization of VM
java.lang.Error: Properties init: Could not determine current working directory.
        at java.lang.System.initProperties(Native Method)
        at java.lang.System.initializeSystemClass(System.java:1072)
<Result-b59c>

<Result-b63>
bash-3.00$ pwd
/home/rg157576/vittal
bash-3.00$ /net/sqindia.india/export/disk09/jdk/1.6.0/b63/binaries/solsparc/bin/java -version
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xff2aea90, pid=18142, tid=2
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-rc-b63 mixed mode)
# Problematic frame:
# C  [libc.so.1+0x2ea90]  strlen+0x50
#
# An error report file with more information is saved as /tmp/hs_err_pid18142.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Abort
</Result-b63>
Error report file is attached.

To reproduce
1. Create a directory say temp
2. move to temp
3. change temp permissions to 077 (Use other terminal)
4. Now run java -version.

In the above scenario jvm will fail to determine current directoy that leads to crash.

Comments
EVALUATION Hotspot eng confirmed this problem was caused by CR 6253381 and fixed by CR 6361259.
10-03-2006

SUGGESTED FIX This just moves the failure further along. See the Eval.
10-03-2006

SUGGESTED FIX GetJavaProperties should probably return NULL when something goes wrong. Maybe it should also memset all discovered values back to zero bits, just to be sure. Something like: @@ -5,6 +5,7 @@ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ +#include <stddef.h> #ifdef __linux__ #include <stdio.h> #include <ctype.h> @@ -97,7 +98,9 @@ #define P_tmpdir "/var/tmp" #endif -/* This function gets called very early, before VM_CALLS are setup. +/* + * Returns a filled-in java_props, or NULL if an exception occurred. + * This function gets called very early, before VM_CALLS are setup. * Do not use any of the VM_CALLS entries!!! */ java_props_t * @@ -388,10 +391,11 @@ { char buf[MAXPATHLEN]; errno = 0; - if (getcwd(buf, sizeof(buf)) == NULL) + if (getcwd(buf, sizeof(buf)) == NULL) { JNU_ThrowByName(env, "java/lang/Error", "Properties init: Could not determine current working directory."); - else + return NULL; + } sprops.user_dir = strdup(buf); }
10-01-2006

EVALUATION The root cause of this problem turns out to have been staring us in the face: failure of the VM to deliver the Error up to System.initializeSystemClass. So making that method's code detect a null properties object passed back from initializeProperties would just be making up for the more basic failure in the system. There is no need for initializeProperties to return null (or zero out the information) because when the VM is working properly control cannot proceed and cause the second order failure. The remaining question (for the VM team) is whether the "exception loss" went away with their build 65 by luck or with an explicit fix? I'm holding this open until that can be determined.
10-01-2006