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

exception loses its stacktrace

XMLWordPrintable

    • x86
    • windows_7

      FULL PRODUCT VERSION :
      found with jre16_30, also exists in jre16_32, jre7u4, and back to jre6_10.
      (only 32 bit versions were tested)

      FULL OS VERSION :
      win7x64 prof on amd

      A DESCRIPTION OF THE PROBLEM :
      attached program is extract of larger application. app has problem and throws ArrayIndexOutOfBoundsException. The exception and its stacktrace is printed in System.err.
      after a number of logged exceptions the stacktrace is no longer printed, just name of exception.
      problem shows with -server, seems to work without -server (or shows much later).

      it seems, when the test-program is too simplistic, error doesnt show.
      the attached version should be fine (that is, showing the problem).

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile and run attached program with -server


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      stacktrace should always be printed
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      .... lots of these .....
      java.lang.ArrayIndexOutOfBoundsException: 142
      at HGM.utils.TestStackTrace.doIt(TestStackTrace.java:23)
      at HGM.utils.TestStackTrace.doItNTimes(TestStackTrace.java:35)
      at HGM.utils.TestStackTrace.main(TestStackTrace.java:48)

      ..... and then these...... - no stacktrace

      java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package HGM.utils;

      public class TestStackTrace {

          int[] array = new int[ 30 ];

          TestStackTrace(){
          }

          void doIt(){
              int sum = 0;
              for ( int i= 0; i < 50; i++ ){
                  for( int j= 0; j <= array.length; j++ ){
                      sum += array[ j ];
                      array[ j ] = i;
                  }
              }
          }

          void doItNTimes( int nTimes ){

              for ( int i= 0; i < nTimes; i++ ){
                  array = new int[ i ];
                  try {
                      doIt();
                  } catch( Throwable ex ){
                      //System.err.println("error:" + ex.getMessage() );
                      ex.printStackTrace( System.err );
                  }
              }
          }

          public static void main( String[] args ){

              TestStackTrace tst = new TestStackTrace();
              tst.doItNTimes( 159 );

          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      no workaround. however, in real app in normal behavior this wasnt observed, even with 'some' exceptions of all kinds occuring.

      scary thing is the age, is reproducible with jre6_10.

            vlivanov Vladimir Ivanov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: