JDK-6352819 : -Xloggc in _JAVA_OPTIONS logs to garbage filename
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-11-18
  • Updated: 2017-09-14
  • Resolved: 2005-12-21
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.
Other JDK 6
1.4.2_12Fixed 6 b65Fixed
Description
FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux xxx 2.6.13.1 #1 Sun Sep 18 00:30:39 BST 2005 i686 i686 i386 GNU/Linux (Red Hat Fedora Core 4)
Linux xxx 2.4.21-27.0.2.EL #1 Wed Jan 12 23:46:37 EST 2005 i686 i686 i386 GNU/Linux (Red Hat Enterprise Linux ES release 3 )

A DESCRIPTION OF THE PROBLEM :
The -Xloggc:filename option does not work when used from the _JAVA_OPTIONS environment variable.  Sometimes, it is simply ignored, and the GC log appears on the console.  Sometimes, the GC log is logged, but to a file with a filename consisting of random characters.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ ls
HelloWorld.java
$ _JAVA_OPTIONS="-Xloggc:gc" javac HelloWorld.java
Picked up _JAVA_OPTIONS: -Xloggc:gc
0.000: [GC 512K->157K(8128K), 0.0162910 secs]
[....]

Or sometimes:

$ ls
HelloWorld.java
$ _JAVA_OPTIONS="-Xloggc:gc" javac HelloWorld.java
Picked up _JAVA_OPTIONS: -Xloggc:gc
$ ls
HelloWorld.class  HelloWorld.java  ??����??����t?����???DP??D
$ cat *D
0.000: [GC 512K->157K(8128K), 0.0088680 secs]
[...]

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The -Xlogg:gc should cause the GC log to be recorded to the file gc when used in _JAVA_OPTIONS, just as when used on the command line.
ACTUAL -
See above.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The HelloWorld.java code referred to above is not relevant to the problem, but for completeness:

HelloWorld.java:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Put -Xloggc options on the command line.  However, this prevents JDK1.5 being a drop-in replacement for JDK1.4.2.

Comments
EVALUATION From ramki: Looks like in arguments.cpp there is a bug in initializing >>_gc_log_filename, which uses a stack allocated char array >>instead of using strdup to allocate storage for the string >>rather than relying on the stack-storage to stay around >>unchanged after the call :-) >> >>for example, doing something along the lines of: >> >>< _gc_log_filename = tail; >>--- >> >> >>>> _gc_log_filename = strdup(tail);
07-12-2005