Program: 52249
Project: 52249
Buggy source:
/** 
 * Creates a new Excerpt containing and index which will be 1L << 17L bytes long, This method is used for creating both the primary and secondary indexes. Chronicle Queue uses a root primary index ( each entry in the primary index points to a unique a secondary index. The secondary index only records the address of every 64th except, the except are linearly scanned from there on.
 * @return the address of the Excerpt containing the usable index, just after the header
 */
long newIndex(){
  long indexSize=1L << 17L;
  try (DirectStore allocate=DirectStore.allocate(6)){
    final DirectBytes buffer=allocate.bytes();
    new BinaryWire(buffer).write(() -> "String_Node_Str");
    buffer.flip();
    final long keyLen=buffer.limit();
    final long length=buffer.remaining();
    if (length > MAX_LENGTH)     throw new IllegalStateException("String_Node_Str" + length);
    final LongValue writeByte=header.writeByte;
    final long lastByte=writeByte.getVolatileValue();
    for (; ; ) {
      if (bytes.compareAndSwapInt(lastByte,0,NOT_READY | (int)length)) {
        long lastByte2=lastByte + 4 + buffer.remaining()+ indexSize;
        bytes.write(lastByte + 4,buffer);
        header.lastIndex.addAtomicValue(1);
        writeByte.setOrderedValue(lastByte2);
        bytes.writeOrderedInt(lastByte,(int)(6 + indexSize));
        long start=lastByte + 4;
        bytes.zeroOut(start + keyLen,start + keyLen + length);
        return start + keyLen;
      }
      int length2=length30(bytes.readVolatileInt());
      bytes.skip(length2);
      Jvm.checkInterrupted();
    }
  }
 }

Fixed version (ground truth):
/** 
 * Creates a new Excerpt containing and index which will be 1L << 17L bytes long, This method is used for creating both the primary and secondary indexes. Chronicle Queue uses a root primary index ( each entry in the primary index points to a unique a secondary index. The secondary index only records the address of every 64th except, the except are linearly scanned from there on.
 * @return the address of the Excerpt containing the usable index, just after the header
 */
long newIndex(){
  long indexSize=1L << 17L;
  try (NativeStore<Void> allocate=NativeStore.nativeStore(6)){
    final Bytes<Void> buffer=allocate.bytes();
    new BinaryWire(buffer).write(() -> "String_Node_Str");
    buffer.flip();
    final long keyLen=buffer.limit();
    final long length=buffer.remaining();
    if (length > MAX_LENGTH)     throw new IllegalStateException("String_Node_Str" + length);
    final LongValue writeByte=header.writeByte();
    final long lastByte=writeByte.getVolatileValue();
    for (; ; ) {
      if (bytes.compareAndSwapInt(lastByte,0,NOT_READY | (int)length)) {
        long lastByte2=lastByte + 4 + buffer.remaining()+ indexSize;
        bytes.write(lastByte + 4,buffer);
        header.lastIndex().addAtomicValue(1);
        writeByte.setOrderedValue(lastByte2);
        bytes.writeOrderedInt(lastByte,(int)(6 + indexSize));
        long start=lastByte + 4;
        bytes.zeroOut(start + keyLen,start + keyLen + length);
        return start + keyLen;
      }
      int length2=length30(bytes.readVolatileInt());
      bytes.skip(length2);
      Jvm.checkInterrupted();
    }
  }
 catch (  Exception e) {
    throw new IORuntimeException(e);
  }
}