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

corba comm_failure timeout due to spurious wakeups

XMLWordPrintable

    • linux_redhat_6.2

      FULL PRODUCT VERSION :
      java 1.6.038 64bit

      ADDITIONAL OS VERSION INFORMATION :
      linux red hat 6.3 64bit

      A DESCRIPTION OF THE PROBLEM :
      In package com.sun.corba.se.impl.encoding;
      the BufferManagerReadStream's underflow method
      contains the following code:

                  while (fragmentQueue.size() == 0) {

                      if (endOfStream) {
                            throw wrapper.endOfStream() ;
                      }

                      boolean interrupted = false;
                      try {
                          fragmentQueue.wait(FRAGMENT_TIMEOUT);
                      } catch (InterruptedException e) {
                          interrupted = true;
                      }

                      if (!interrupted && fragmentQueue.size() == 0) {
                          throw wrapper.bufferReadManagerTimeout();
                      }

                      if (receivedCancel) {
                          throw new RequestCanceledException(cancelReqId);
                      }
                  }

      If a spurious wakeup happens, the queue size may still be zero resulting
      in timeout exception.
      This is not handled by the statment

                      if (!interrupted && fragmentQueue.size() == 0) {
                          throw wrapper.bufferReadManagerTimeout();
                      }

       Make sure timeout occured before exception is given.

      Possible solution:

                  while (fragmentQueue.size() == 0) {

                      if (endOfStream) {
       throw wrapper.endOfStream() ;
                      }

                      boolean interrupted = false;
                      long timeWaited = 0;
                      try {
                           timeWaited = System.currentTimeMillis();
                           fragmentQueue.wait(FRAGMENT_TIMEOUT);
       timeWaited = System.currentTimeMillis() - timeWaited;
                      } catch (InterruptedException e) {
                          interrupted = true;
                      }

                      if (!interrupted && fragmentQueue.size() == 0 && timeWaited >= FRAGMENT_TIMEOUT) {
                          throw wrapper.bufferReadManagerTimeout();
                      }

                      if (receivedCancel) {
                          throw new RequestCanceledException(cancelReqId);
                      }
                  }



      REGRESSION. Last worked in version 5.0

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Code inspection.

      ACTUAL -
      Corba comm_failure timout occured randomly without any communication or memory problems.
      Instrumentation of the code given the exception by measure time used in execution was done: found out that 0-1 ms was used when exception was given,
      i.e nothing near the timeout of 60 sec used in code.

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

            coffeys Sean Coffey
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: