JDK-4883187 : HotSpot debug build dumps core if current directory not found
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Cannot Reproduce
  • OS: solaris_7
  • CPU: generic
  • Submitted: 2003-06-24
  • Updated: 2013-09-09
  • Resolved: 2013-09-09
Related Reports
Relates :  
Description
If you try to run HotSpot debug build when the current working directory 
can't be determined (e.g., it's been removed), the JVM crashes.

Steps to reproduce the problem:

In shell 1:

    $ mkdir Foo
    $ cd Foo

In shell 2:

    $ rmdir Foo

Back in shell 1:

    $ $Deployed/JDK-1.5.0/bin/java_g -version
    Warning:  Cannot open log file: hotspot.log
    Warning:  Forcing option -XX:LogFile=/tmp//hs_pid3449.log
    Error occurred during initialization of VM
    java.lang.Error: Properties init: Could not determine current working directory.
    Dumping core....
    Abort

Of course, dbx is no help in this situation:

    $ dbx $Deployed/JDK-1.5.0/bin/java_g core
    fatal error: Cannot find run directory for dbx -- Error 0

and anyway, since there's no current directory, there's no core file to debug:

    $ ls -l core
    core not found

The java.lang.Error comes from 

    /java/re/jdk/1.5.0/latest/ws/j2se/src/solaris/native/java/lang/java_props_md.c

and the stack trace looks like it would be: 

    getcwd(buf, sizeof(buf))                                         in java_props_md.c
    java_props_t *sprops = GetJavaProperties(env);                   in System.c
    initProperties(props);                                           in System.java
    JavaCalls::call_static(.... initializeSystemClass_name(), ....)  in thread.cpp
    call_initializeSystemClass(CHECK_0);                             in thread.cpp
    jint result = Threads::create_vm((JavaVMInitArgs*) args);        in jni.cpp
    r = ifn->CreateJavaVM(pvm, (void **)penv, &args);                in java.c

I'm not sure who is being surprised by the exception and dumping 
core.  The product build puts out the error message and then seems 
to exit cleanly, so I'm lowering the priority.

Comments
As of jdk8 b106, the (fast)debug build does not dump core, but instead behaves the same as the standard build (exits cleanly, without dumping core): % /java/re/jdk/8.0/promoted/all/b106/binaries/solaris-sparc/fastdebug/bin/java -version Warning: Cannot open log file: hotspot.log Warning: Forcing option -XX:LogFile=/tmp/hs_pid17562.log 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:1160)
09-09-2013

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
14-06-2004

EVALUATION getcwd() returns NULL if current directory does not exist, this will cause GetJavaProperties() to throw java.lang.Error. But this happens before VM is fully initialized; VM can't throw the exception but instead it will abort in vm_exit_during_initialization(). The error can happen in product build too. Reassign to java/classes_lang. Please see if it's possible to silently ignore the getcwd() error. ###@###.### 2003-09-09 If an application doesn't use relative paths in the file system or access the user.dir system property, it should not fail. System properties that are expensive to compute (such as user.dir) or might fail should be computed lazily, not unconditionally at JVM startup. This is probably too risky to fix for Tiger. ###@###.### 2003-11-06
06-11-2003