Diagnosing a java.lang.StackOverflowError on Windows

Technote (FAQ)
Problem
Determining the cause of java.lang.StackOverflowErrors for WebSphere® Application Server running on Windows® platforms. Includes recommended actions to correct the problems.
Cause
When a stack overflow occurs, the amount of stack space required by the program exceeds what is configured for the stack in the Java™ virtual machine (JVM™) process. A stack overflow can result from:
  • A deeply nested application
  • An infinite loop within an application
  • A problem in just-in-time- (JIT) compiled code

A stack overflow is not always caused by a problem in a Java program. Some programs require stacks that are larger than the default size; for example, a graphics-intensive Java program can require a larger stack.
Solution

Overview
You can configure two stack size parameters for Java code:
  • The -Xss parameter for the native stack, used by Java code to process calls made into native libraries.
  • The -Xoss parameter for the Java stack, used for Java method calls to track the state of variables.

For each thread in the JVM, there is a Java stack and a native stack. Default values include:

Platform
-Xoss (Java stack size)
-Xss (native stack size)
WindowsDefault: 400 KB Minimum: 100 KB Maximum: None specified Default: 512 KB Minimum: 96 KB Maximum: None specified

Ask the following questions:
  • Does a stack overflow exist in native code or in Java code?
    1. View the Java stack trace associated with the stack overflow, if this information is available.
    2. Be aware that the information that is returned when the stack overflow occurs is dependent upon the platform.
    3. Realize that in many cases it is not possible to get complete or usable information.
  • Does there appear to be an infinite loop?
    1. Verify if the pattern of calls repeats. Is a recursive loop of calls occurring?
    2. View the source code or use a debugger to determine if a deep stack is normal, even with some repeat calls in the stack trace.
    3. If there does not appear to be a loop, increase either the Java stack or the native stack to resolve the problem.

Diagnosing a stack overflow on Windows systems

The symptoms of a stack overflow include:
  • A StackOverFlowError in the system out or system error file. This error is not always a terminating exception. The Java process might continue to run.
  • A very deep stack that does not include a stack overflow. This situation is typically a terminating exception, or the result of requesting a thread dump (Java core).
  • Stack overflow usually results in a JVM crash. When that occurs, a DrWtsn32 log is usually generated and contains errors such as:

    DrWtsn32.log: (Search on pid=10492)
    Exception number: c00000fd (stack overflow
    FAULT ->708b53ff 51 push ecx
    708b5400 52 push edx
    708b5401 ff1504ffbd70 call dword ptr 70bdff04 ds:70bd
    708b5407 83c40c add esp,0xc
  • jdump output usually identifies the existence of a stack overflow in a thread.
    For example, this is output from a native stack overflow.
    *** CHECK *** possible thread stack overflow (FFFFED1C) by r15 (00000000)
    *** ERROR *** stack trace possibly aborted (000018A0 left untraced)

    A second example:
    *** ERROR *** definite thread stack overflow (31BA3FE4 < 31BA4000)
  • When a stack overflow occurs, the javacore file might identify a stack overflow in a thread.

    Example:

    "Worker#12" (TID:0x82925a78, sys_thread_t:0x322bdb18, state:R, native ID:0x2022) prio=5
    ----- Native Stack -----
    unable to backtrace through native code - iar 0x7 not in text area (sp is 0x32ee0e00)


What to do with a Java stack or native overflow

To fix a Java stack or native overflow:

  1. Increase the size of the appropriate stack incrementally.
  2. Test.
  3. Repeat these actions until the error is eliminated. To change this stack value from the default size, specify a new value in the command line arguments of the WebSphere Application Server.

Notes:

  • The suggested starting point is double the default stack size.
  • Remember that increasing the stack size increases the memory required for each thread.
  • The appropriate value can change when the Java 2 SDK is upgraded.
  • Increasing the stack is not the solution if OutOfMemoryError exceptions occur with an increased stack size.
  • If increasing the stack sizes does not work, the following options might still resolve the problem:
Related information
Disable JIT Compiler in V4

Disable JIT Compiler in V5

Java SDK Parameters












Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Java SDK
Operating system(s): Windows
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Software edition: Edition Independent
Reference #: 1162896
IBM Group: Software Group
Modified date: 2004-11-16