United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6352819 -Xloggc in _JAVA_OPTIONS logs to garbage filename
JDK-6352819 : -Xloggc in _JAVA_OPTIONS logs to garbage filename

Details
Type:
Bug
Submit Date:
2005-11-18
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2005-12-21
Component:
hotspot
OS:
linux
Sub-Component:
runtime
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

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);
                                     
2005-12-07



Hardware and Software, Engineered to Work Together