Program: 34356
Project: 34356
Buggy source:
@Override public Binary put(Binary key,Binary value){
  final byte[] keyData=key.getValue();
  final int keySize=keyData.length;
  final int hash=Math.abs(hashFunction.apply(keyData));
  final long offset=hash % partitionCount;
  long locationAddress=unsafe.getAddress(partitionAddress + (offset * addressSize));
  int entryCount=locationAddress == 0 ? 0 : unsafe.getInt(locationAddress);
  locationAddress+=Integer.BYTES;
  for (long locationOffset=0; locationOffset < entryCount; locationOffset++) {
    long keyAddress=unsafe.getAddress(locationAddress + (locationOffset * addressSize * 2));
    int size=unsafe.getInt(keyAddress);
    if (size != keySize)     continue;
    keyAddress+=Integer.BYTES;
    boolean isEqual=true;
    for (int keyOffset=0; keyOffset < keySize; keyOffset++) {
      if (keyData[keyOffset] != unsafe.getByte(keyAddress + keyOffset)) {
        isEqual=false;
        break;
      }
    }
    if (isEqual) {
      long valueAddress=unsafe.getAddress(locationAddress + (locationOffset * addressSize * 2) + addressSize);
      Binary oldValue=null;
      if (valueAddress != 0) {
        int valueSize=unsafe.getInt(valueAddress);
        byte[] valueData=new byte[valueSize];
        valueAddress+=Integer.BYTES;
        for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
          valueData[valueOffset]=unsafe.getByte(valueAddress + valueOffset);
        }
        oldValue=new Binary(valueData);
        valueAddress-=Integer.BYTES;
        unsafe.freeMemory(valueAddress);
      }
      if (value != null) {
        byte[] valueData=value.getValue();
        int valueSize=valueData.length;
        valueAddress=allocate(Integer.BYTES + valueSize,false);
        unsafe.putInt(valueAddress,valueSize);
        for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
          unsafe.putByte(valueAddress + valueOffset + Integer.BYTES,valueData[valueOffset]);
        }
      }
 else {
        valueAddress=0;
      }
      unsafe.putAddress(locationAddress + (locationOffset * addressSize * 2) + addressSize,valueAddress);
      return oldValue;
    }
  }
  itemCount++;
  locationAddress-=Integer.BYTES;
  long keyAddress=allocate(Integer.BYTES + keySize,false);
  unsafe.putInt(keyAddress,keySize);
  for (int keyOffset=0; keyOffset < keySize; keyOffset++) {
    unsafe.putByte(keyAddress + Integer.BYTES + keyOffset,keyData[keyOffset]);
  }
  long valueAddress=0;
  if (value != null) {
    byte[] valueData=value.getValue();
    int valueSize=valueData.length;
    valueAddress=allocate(Integer.BYTES + valueSize,false);
    unsafe.putInt(valueAddress,valueSize);
    for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
      unsafe.putByte(valueAddress + Integer.BYTES + valueOffset,valueData[valueOffset]);
    }
  }
  if (locationAddress == 0) {
    locationAddress=allocate(Integer.BYTES + addressSize + addressSize,false);
  }
 else {
    locationAddress=unsafe.reallocateMemory(locationAddress,Integer.BYTES + (addressSize * 2 * (entryCount + 1)));
  }
  unsafe.putAddress(locationAddress + Integer.BYTES + (addressSize * 2 * entryCount),keyAddress);
  unsafe.putAddress(locationAddress + Integer.BYTES + (addressSize * 2 * entryCount)+ addressSize,valueAddress);
  unsafe.putInt(locationAddress,entryCount + 1);
  unsafe.putAddress(partitionAddress + (offset * addressSize),locationAddress);
  return null;
}

Fixed version (ground truth):
@Override public Binary put(Binary key,Binary value){
  final byte[] keyData=key.getValue();
  final int keySize=keyData.length;
  final long offset=getPartitionOffset(keyData);
  long locationAddress=unsafe.getAddress(partitionAddress + (offset * addressSize));
  int entryCount=locationAddress == 0 ? 0 : unsafe.getInt(locationAddress);
  locationAddress+=Integer.BYTES;
  for (long locationOffset=0; locationOffset < entryCount; locationOffset++) {
    long keyAddress=unsafe.getAddress(locationAddress + (locationOffset * addressSize * 2));
    int size=unsafe.getInt(keyAddress);
    if (size != keySize)     continue;
    keyAddress+=Integer.BYTES;
    boolean isEqual=true;
    for (int keyOffset=0; keyOffset < keySize; keyOffset++) {
      if (keyData[keyOffset] != unsafe.getByte(keyAddress + keyOffset)) {
        isEqual=false;
        break;
      }
    }
    if (isEqual) {
      long valueAddress=unsafe.getAddress(locationAddress + (locationOffset * addressSize * 2) + addressSize);
      Binary oldValue=null;
      if (valueAddress != 0) {
        int valueSize=unsafe.getInt(valueAddress);
        byte[] valueData=new byte[valueSize];
        valueAddress+=Integer.BYTES;
        for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
          valueData[valueOffset]=unsafe.getByte(valueAddress + valueOffset);
        }
        oldValue=new Binary(valueData);
        valueAddress-=Integer.BYTES;
        unsafe.freeMemory(valueAddress);
      }
      if (value != null) {
        byte[] valueData=value.getValue();
        int valueSize=valueData.length;
        valueAddress=allocate(Integer.BYTES + valueSize,false);
        unsafe.putInt(valueAddress,valueSize);
        for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
          unsafe.putByte(valueAddress + valueOffset + Integer.BYTES,valueData[valueOffset]);
        }
      }
 else {
        valueAddress=0;
      }
      unsafe.putAddress(locationAddress + (locationOffset * addressSize * 2) + addressSize,valueAddress);
      return oldValue;
    }
  }
  itemCount++;
  locationAddress-=Integer.BYTES;
  long keyAddress=allocate(Integer.BYTES + keySize,false);
  unsafe.putInt(keyAddress,keySize);
  for (int keyOffset=0; keyOffset < keySize; keyOffset++) {
    unsafe.putByte(keyAddress + Integer.BYTES + keyOffset,keyData[keyOffset]);
  }
  long valueAddress=0;
  if (value != null) {
    byte[] valueData=value.getValue();
    int valueSize=valueData.length;
    valueAddress=allocate(Integer.BYTES + valueSize,false);
    unsafe.putInt(valueAddress,valueSize);
    for (int valueOffset=0; valueOffset < valueSize; valueOffset++) {
      unsafe.putByte(valueAddress + Integer.BYTES + valueOffset,valueData[valueOffset]);
    }
  }
  if (locationAddress == 0) {
    locationAddress=allocate(Integer.BYTES + addressSize + addressSize,false);
  }
 else {
    locationAddress=unsafe.reallocateMemory(locationAddress,Integer.BYTES + (addressSize * 2 * (entryCount + 1)));
  }
  unsafe.putAddress(locationAddress + Integer.BYTES + (addressSize * 2 * entryCount),keyAddress);
  unsafe.putAddress(locationAddress + Integer.BYTES + (addressSize * 2 * entryCount)+ addressSize,valueAddress);
  unsafe.putInt(locationAddress,entryCount + 1);
  unsafe.putAddress(partitionAddress + (offset * addressSize),locationAddress);
  return null;
}