Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-20863

Integer overflow in SupportLogHandler

XMLWordPrintable

      This issue is essentially identical to JENKINS-9120, where an integer gets incremented but never decremented. After a large number of calls, the integer overflows.

      SEVERE: Error within request handler thread
      java.lang.ArrayIndexOutOfBoundsException: -255
      at com.cloudbees.jenkins.support.SupportLogHandler.publish(SupportLogHandler.java:106)
      at java.util.logging.Logger.log(Logger.java:570)
      at java.util.logging.Logger.doLog(Logger.java:592)
      at java.util.logging.Logger.log(Logger.java:681)
      at winstone.Logger.logInternal(Logger.java:157)
      at winstone.Logger.log(Logger.java:183)
      at winstone.HttpListener.allocateRequestResponse(HttpListener.java:182)
      at winstone.RequestHandlerThread.run(RequestHandlerThread.java:69)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:701)

      The problem is here in SupportLogHandler's publish method:

      int maxCount = records.length;
      records[(position + count) % maxCount] = record;
      if (count == maxCount) {
      position++;
      } else {
      count++;
      }

      Once count is equal to maxCount, count will never be incremented. However, position will be incremented indefinitely from then on. Position should instead be set to something like this:

      position = (position + 1) % maxCount;

            jglick Jesse Glick
            jgibbs Josh Gibbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: