Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6455

Infinite loop in NetworkServerControlImpl.ensureDataInBuffer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 10.10.1.1
    • 10.10.2.0, 10.11.1.1
    • Network Server
    • None
    • High Value Fix, Known fix
    • Performance, Seen in production

    Description

      NetworkServerControlImpl.ensureDataInBuffer missing check for return -1 (EOF) from 'clientIs.read'. When read returns -1 thread consumes 100% CPU. Method NetworkServerControlImpl.fillReplyBuffer correctly throw exception.

      Fix: add two lines:
      private void ensureDataInBuffer(int minimumBytesNeeded) throws Exception
      {
      // make sure the buffer is large enough
      while ((replyBufferCount - replyBufferPos) < minimumBytesNeeded)
      {
      try

      { int bytesRead = clientIs.read(replyBuffer, replyBufferCount, replyBuffer.length - replyBufferCount); + if (bytesRead == -1) + consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true); replyBufferCount += bytesRead; }

      catch (IOException e)

      { clientSocketError(e); }

      }
      }

      StackTrace:
      java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.read(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.ensureDataInBuffer(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.readLDString(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.readStringReply(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.runtimeInfo(Unknown Source:-1)
      at org.apache.derby.drda.NetworkServerControl.getRuntimeInfo(Unknown Source:-1)
      at com.crcdata.dbadmin.server.DerbyEngine.getRuntimeInfo(DerbyEngine.java:134)
      at com.crcdata.dbadmin.server.DerbyEngine$DerbyServerMonitorTask.run(DerbyEngine.java:305)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source:-1)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source:-1)
      at java.util.concurrent.FutureTask.run(Unknown Source:-1)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source:-1)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source:-1)
      at java.lang.Thread.run(Unknown Source:-1)

      Attachments

        1. d6455-1a.diff
          5 kB
          Knut Anders Hatlen

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jandam@crcdata.cz Martin JANDA
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: