Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-542

ArrayIndexOutOfBoundsException in CircularQueue.shrinkIfNeeded()

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.0.0-M1
    • 2.0.0-M2
    • Core
    • None

    Description

      ArrayIndexOutOfBoundsException is raised by CircularQueue.shrinkIfNeeded() when the size of the queue is 0:

      java.lang.ArrayIndexOutOfBoundsException
      at org.apache.mina.util.CircularQueue.shrinkIfNeeded(CircularQueue.java:233)
      at org.apache.mina.util.CircularQueue.poll(CircularQueue.java:108)
      at
      org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)
      at
      org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:187)
      at
      org.apache.mina.common.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:401)
      at
      org.apache.mina.common.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:38)
      at
      org.apache.mina.common.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:820)
      at
      org.apache.mina.common.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:604)
      at
      org.apache.mina.common.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:401)
      at
      org.apache.mina.common.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:395)
      at
      org.apache.mina.common.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:425)
      at
      org.apache.mina.common.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:387)
      at
      org.apache.mina.common.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:379)
      at
      org.apache.mina.common.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:43)
      at
      org.apache.mina.common.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:676)
      at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
      at
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:619)

      Attachments

        Activity

          trustin Trustin Lee added a comment -

          Fixed with reproducing test case.

          trustin Trustin Lee added a comment - Fixed with reproducing test case.
          trustin Trustin Lee added a comment -

          I found that the test passes with the byte code generated by Eclipse Java Compiler but fails with SUN Java Compiler. CircularQueueTest fails randomly. We cannot say that it's a concurrency issue because the test runs in a single thread. It looks definitely like a JVM or compiler bug - probably SUN VM doesn't like the code SUN Java Compiler produced or the byte code that SUN Java Compiler produced is wrong.

          Changing one field in CircularQueue to be volatile works around the problem, but I didn't figure out why exactly it fixes the problem - SUN JVM might be optimizing CircularQueue in a wrong way and the volatile field might be preventing bad optimization.

          trustin Trustin Lee added a comment - I found that the test passes with the byte code generated by Eclipse Java Compiler but fails with SUN Java Compiler. CircularQueueTest fails randomly. We cannot say that it's a concurrency issue because the test runs in a single thread. It looks definitely like a JVM or compiler bug - probably SUN VM doesn't like the code SUN Java Compiler produced or the byte code that SUN Java Compiler produced is wrong. Changing one field in CircularQueue to be volatile works around the problem, but I didn't figure out why exactly it fixes the problem - SUN JVM might be optimizing CircularQueue in a wrong way and the volatile field might be preventing bad optimization.

          The bug in the JVM was tracked down by Tuure Laurinolli :
          http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7048332

          elecharny Emmanuel Lécharny added a comment - The bug in the JVM was tracked down by Tuure Laurinolli : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7048332

          People

            trustin Trustin Lee
            trustin Trustin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: