Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6548451

Lost cause in stack trace deeper than stack trace depth

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 6
    • hotspot
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      The maximum number of lines of stack that may be reported in a trace is a function of Throwable.getStackTraceDepth(). If the important part of the stack, i.e. that part required for problem diagnosis is deeper than stack trace depth, the stack trace is useless.

      We need some more intelligent way to report stack information when the stack is larger than stack trace depth.
       

      JUSTIFICATION :
      t seems arbitrary to assume that the interesting part of the stack is always that bit on the top. During infinite recursion, we see a trace of cycles between methods resulting in a Stack Overflow. Seeing hundreds of cycles in the stack is of no help when one cares about how the cycles started.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      One way to address this problem is with a new JVM parameter that describes what part of a stack to report when the stack is larger then stack trace depth.

      Of course, by default or when stack depth is less than stack trace depth, the JVM behaves as it does today. But imagine a new -X parameter:
         -XstackBottom=0
         -XstackBottom=1024

      In the first case, the reported stack would be relative to the bottom of the stack. In the second case, the reported stack would be in the middle, starting 1024 stack trace elements from the bottom of the stack.

      Given the program in 'Source Code' below, I would like to see the following call result in the following stack trace:

      java -XstackBottom=0
      .....
      at Main.a(Main.java:5)
      at Main.c(Main.java:16)
      at Main.b(Main.java:8)
      at Main.a(Main.java:5)
      at Main.c(Main.java:16)
      at Main.b(Main.java:8)
      at Main.main(Main.java:20)


      ACTUAL -
        Today, I see this stack trace. It is not possible to tell which method started the infinite recursion.

      Exception in thread "main" java.lang.StackOverflowError
      at Main.a(Main.java:5)
      at Main.c(Main.java:11)
      at Main.b(Main.java:8)
      .....
      at Main.c(Main.java:11)
      at Main.b(Main.java:8)
      at Main.a(Main.java:5)




      ---------- BEGIN SOURCE ----------
      public class Main {
      private void a() {
      b();
      }
      private void b() {
      c();
      }
      private void c() {
      a();
      }
      public static void main(String[] args) {
      Main m = new Main();
      m.b();
      }
      }


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

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: