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

(timer) Timer.TaskQueue is susceptible to ArrayIndexOutOfBounds after OutOfMemoryError

XMLWordPrintable

    • b71
    • x86
    • linux

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Timer.TaskQueue.add() does not gracefully handle OutOfMemoryError's. In the following code:

          void add(TimerTask task) {
              // Grow backing store if necessary
              if (++size == queue.length) {
                  TimerTask[] newQueue = new TimerTask[2*queue.length];
                  System.arraycopy(queue, 0, newQueue, 0, size);
                  queue = newQueue;
              }
                                                                                                                                                       
              queue[size] = task;
              fixUp(size);
          }

      an OutOfMemoryError thrown while expanding the queue will result in size being larger than queue.length.

      It should be simple to fix by testing against (size + 1) and incrementing size after the if block.


      REPRODUCIBILITY :
      This bug can be reproduced always.

            martin Martin Buchholz
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: