JDK-4872096 : no stack trace on java.lang.StackOverflowError makes it hard to locate bugs
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2003-05-30
  • Updated: 2012-10-08
  • Resolved: 2003-07-22
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
5.0 tigerFixed
Description

Name: rmT116609			Date: 05/30/2003


FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
There is no stack trace emitted in the case of a java.lang.StackOverflowError exception.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java
java Test

See the file Test.java included below, containing an infinite recursion error which leads to stack overflow.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In the previous version:

java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

The output is as expected:

D:\lithium\mb7.2\src\test>java Test
Exception in thread "main" java.lang.StackOverflowError
        at Test$Oops.toString(Test.java:10)
        at java.lang.String.valueOf(String.java:2177)
        at java.lang.StringBuffer.append(StringBuffer.java:361)
        at Test$Oops.toString(Test.java:10)
        at java.lang.String.valueOf(String.java:2177)
        at java.lang.StringBuffer.append(StringBuffer.java:361)
<<many pages of the above repeated>>
ACTUAL -
D:\lithium\mb7.2\src\test>java Test
Exception in thread "main" java.lang.StackOverflowError

<<no additional output>>

ERROR MESSAGES/STACK TRACES THAT OCCUR :
none emitted, that's the bug

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

public class Test {
    static class Oops {
        private String name;

        public Oops(String name) {
            this.name = name;
        }

        public String toString() {
            return "[group=" + this + name + "]";
        }
    }

    public static void main(String[] args) {
        Oops a = new Oops("foo");
        System.out.println("" + a);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
none (except reverting to the previous JDK version)
(Review ID: 186786) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_02 tiger FIXED IN: tiger INTEGRATED IN: tiger
14-06-2004

SUGGESTED FIX *** src/share/vm/c1/c1_Runtime1.cpp- Wed Jun 4 14:17:55 2003 (new) --- c1_Runtime1.cpp Wed Jun 4 13:53:37 2003 *** 862,871 **** --- 862,874 ---- // InterpreterRuntime::create_StackOverflowError // klassOop k = SystemDictionary::StackOverflowError_klass(); oop exception = instanceKlass::cast(k)->allocate_instance(CHECK); Handle h_exception = Handle(thread, exception); + if (StackTraceInThrowable) { + java_lang_Throwable::fill_in_stack_trace(h_exception); + } throw_and_post_jvmdi_exception(thread, h_exception); JRT_END *** src/share/vm/utilities/exceptions.cpp- Wed Jun 4 14:17:56 2003 --- exceptions.cpp Wed Jun 4 13:54:00 2003 *** 129,138 **** --- 129,141 ---- void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line) { oop exception; if (!THREAD->has_pending_exception()) { klassOop k = SystemDictionary::StackOverflowError_klass(); exception = instanceKlass::cast(k)->allocate_instance(CHECK); + if (StackTraceInThrowable) { + java_lang_Throwable::fill_in_stack_trace(exception); + } } else { // if prior exception, throw that one instead exception = THREAD->pending_exception(); } _throw_oop(THREAD, file, line, exception);
11-06-2004

PUBLIC COMMENTS The stack trace for StackOverflowError is uninitentionally not generated in the mantis release of the JVM for the client compiler. If stack overflow is the cause of your program termination, try using -Xint to find out what calls led to the overflow. The stack will be restored in the next release for both client and server compilers.
10-06-2004

EVALUATION This has already been fixed in the 1.5 HotSpot workspace as part of 4826722. The lack of backtrace was a side-effect of some stack overflow work done for 1.4.2. However ###@###.### has pointed out that there is no good reason why only the C1 runtime doesn't produce stack traces for stack overflow errors. Making it do so in 1.4.2 would be a very small and low-risk change. ###@###.### 2003-05-30
30-05-2003

WORK AROUND Running with -Xint should produce a stack trace. ###@###.### 2003-05-30
30-05-2003