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

RingBufferLogHandler throws ArrayIndexOutOfBoundsException after int-overflow

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      On our jenkins (1.403) the following exception occured (only a restart can the system bring back to a normal behaviour):

      java.lang.ArrayIndexOutOfBoundsException: -255
      at hudson.util.RingBufferLogHandler.publish(RingBufferLogHandler.java:52)
      at java.util.logging.Logger.log(Unknown Source)
      at java.util.logging.Logger.doLog(Unknown Source)
      at java.util.logging.Logger.log(Unknown Source)
      at java.util.logging.Logger.fine(Unknown Source)
      at hudson.security.SidACL.hasPermission(SidACL.java:54)
      at hudson.security.ACL.checkPermission(ACL.java:52)
      at hudson.model.Node.checkPermission(Node.java:316)
      at hudson.model.Hudson.getTarget(Hudson.java:3409)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:497)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:640)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:478)
      at org.kohsuke.stapler.Stapler.service(Stapler.java:160)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      ... more

      After that all requests to jenkins fail with the same exception.
      The source of RingBufferLogHandler shows the usage of the primitive int's start and size which are incremented but never decremented ...

      private int start = 0;
      private final LogRecord[] records;
      private volatile int size = 0;

      ...

      public synchronized void publish(LogRecord record) {
      int len = records.length;
      records[(start+size)%len]=record;
      if(size==len)

      { start++; }

      else

      { size++; }

      }

      So after a time an overflow occures and cause the ArrayIndexOutOfBoundsException.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Josh Gibbs
            Path:
            core/src/main/java/hudson/util/RingBufferLogHandler.java
            http://jenkins-ci.org/commit/jenkins/67838866c6c851adc8e39dbd20ff81a434cf6cc6
            Log:
            [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Josh Gibbs Path: core/src/main/java/hudson/util/RingBufferLogHandler.java http://jenkins-ci.org/commit/jenkins/67838866c6c851adc8e39dbd20ff81a434cf6cc6 Log: [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oliver Gondža
            Path:
            test/src/test/java/hudson/util/RingBufferLogHandlerTest.java
            http://jenkins-ci.org/commit/jenkins/777d232053488b2dcedc122529283c6e69e99c95
            Log:
            JENKINS-9120 Add test

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: test/src/test/java/hudson/util/RingBufferLogHandlerTest.java http://jenkins-ci.org/commit/jenkins/777d232053488b2dcedc122529283c6e69e99c95 Log: JENKINS-9120 Add test
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #3086
            [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset. (Revision 67838866c6c851adc8e39dbd20ff81a434cf6cc6)
            JENKINS-9120 Add test (Revision 777d232053488b2dcedc122529283c6e69e99c95)

            Result = SUCCESS
            ogondza : 67838866c6c851adc8e39dbd20ff81a434cf6cc6
            Files :

            • core/src/main/java/hudson/util/RingBufferLogHandler.java

            ogondza : 777d232053488b2dcedc122529283c6e69e99c95
            Files :

            • test/src/test/java/hudson/util/RingBufferLogHandlerTest.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #3086 [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset. (Revision 67838866c6c851adc8e39dbd20ff81a434cf6cc6) JENKINS-9120 Add test (Revision 777d232053488b2dcedc122529283c6e69e99c95) Result = SUCCESS ogondza : 67838866c6c851adc8e39dbd20ff81a434cf6cc6 Files : core/src/main/java/hudson/util/RingBufferLogHandler.java ogondza : 777d232053488b2dcedc122529283c6e69e99c95 Files : test/src/test/java/hudson/util/RingBufferLogHandlerTest.java
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oliver Gondža
            Path:
            test/src/test/java/hudson/util/RingBufferLogHandlerTest.java
            http://jenkins-ci.org/commit/jenkins/754ef75447d83767b4485ee8b15bb097f65838c4
            Log:
            JENKINS-9120 Add test

            (cherry picked from commit 777d232053488b2dcedc122529283c6e69e99c95)

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: test/src/test/java/hudson/util/RingBufferLogHandlerTest.java http://jenkins-ci.org/commit/jenkins/754ef75447d83767b4485ee8b15bb097f65838c4 Log: JENKINS-9120 Add test (cherry picked from commit 777d232053488b2dcedc122529283c6e69e99c95)
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Josh Gibbs
            Path:
            core/src/main/java/hudson/util/RingBufferLogHandler.java
            http://jenkins-ci.org/commit/jenkins/9cc2bc21307326fd8f92a0c67401d17357ab0390
            Log:
            [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset.

            (cherry picked from commit 67838866c6c851adc8e39dbd20ff81a434cf6cc6)

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Josh Gibbs Path: core/src/main/java/hudson/util/RingBufferLogHandler.java http://jenkins-ci.org/commit/jenkins/9cc2bc21307326fd8f92a0c67401d17357ab0390 Log: [FIXED JENKINS-9120] RingBufferLogHandler has int that needs to be reset. (cherry picked from commit 67838866c6c851adc8e39dbd20ff81a434cf6cc6)

              People

              • Assignee:
                Unassigned
                Reporter:
                marco_rothe Marco Rothe
              • Votes:
                18 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: