Program: 163034
Project: 163034
Buggy source:
/** 
 * reads entries from the buffer till empty
 * @param attached
 * @throws InterruptedException
 */
private void entriesFromBuffer(Attached attached) throws InterruptedException, IOException {
  for (; ; ) {
    out.limit(in.position());
    if (state == NOT_SET) {
      if (out.remaining() < SIZE_OF_SIZE + 1) {
        return;
      }
      state=out.readByte();
      sizeInBytes=out.readInt();
      long requiredSize=sizeInBytes + SIZE_OF_SIZE + 1;
      if (out.capacity() < requiredSize) {
        attached.entryReader.resizeBuffer(requiredSize + HEADROOM);
      }
      if (state == NOT_SET)       continue;
    }
    if (out.remaining() < sizeInBytes) {
      return;
    }
    final long nextEntryPos=out.position() + sizeInBytes;
    final long limit=out.limit();
    out.limit(nextEntryPos);
    boolean isStateless=(state != 1);
    if (isStateless) {
      if (statelessServerConnector == null) {
        LOG.error("String_Node_Str",new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"));
      }
 else {
        final Work futureWork=statelessServerConnector.processStatelessEvent(state,attached.entryWriter.in,attached.entryReader.out);
        if (futureWork != null) {
          boolean isComplete=futureWork.doWork(attached.entryWriter.in);
          if (!isComplete)           attached.entryWriter.uncompletedWork=futureWork;
        }
      }
    }
 else     externalizable.readExternalEntry(out);
    out.limit(limit);
    out.position(nextEntryPos);
    state=NOT_SET;
    sizeInBytes=0;
  }
}

Fixed version (ground truth):
/** 
 * reads entries from the buffer till empty
 * @param attached
 * @throws InterruptedException
 */
private void entriesFromBuffer(Attached attached) throws InterruptedException, IOException {
  for (; ; ) {
    out.limit(in.position());
    if (state == NOT_SET) {
      if (out.remaining() < SIZE_OF_SIZE + 1) {
        return;
      }
      state=out.readByte();
      sizeInBytes=out.readInt();
      long requiredSize=sizeInBytes + SIZE_OF_SIZE + 1;
      if (out.capacity() < requiredSize) {
        attached.entryReader.resizeBuffer(requiredSize + HEADROOM);
      }
      if (state == NOT_SET)       continue;
    }
    if (out.remaining() < sizeInBytes) {
      return;
    }
    final long nextEntryPos=out.position() + sizeInBytes;
    final long limit=out.limit();
    out.limit(nextEntryPos);
    boolean isStateless=(state != 1);
    if (isStateless) {
      if (statelessServerConnector == null) {
        LOG.error("String_Node_Str",new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"));
      }
 else {
        final Work futureWork=statelessServerConnector.processStatelessEvent(state,attached.entryWriter.in,attached.entryReader.out);
        if (futureWork != null) {
          try {
            boolean isComplete=futureWork.doWork(attached.entryWriter.in);
            if (!isComplete)             attached.entryWriter.uncompletedWork=futureWork;
          }
 catch (          Exception e) {
            LOG.error("String_Node_Str",e);
          }
        }
      }
    }
 else     externalizable.readExternalEntry(out);
    out.limit(limit);
    out.position(nextEntryPos);
    state=NOT_SET;
    sizeInBytes=0;
  }
}