Program: 30886
Project: 30886
Buggy source:
private void openPartitionColumns(int columnIndex,long partitionSize,long[] columnTops){
  int plen=path.length();
  try {
    for (int i=0; i < columnCount; i++) {
      if (columns.getQuick(columnIndex + i * 2) == null) {
        String name=metadata.getColumnName(i);
        if (ff.exists(TableWriter.dFile(path.trimTo(plen),name))) {
          ReadOnlyMemory mem1=new ReadOnlyMemory(ff);
          mem1.of(path);
          columns.setQuick(columnIndex + i * 2,mem1);
switch (metadata.getColumnQuick(i).getType()) {
case ColumnType.STRING:
case ColumnType.SYMBOL:
            columns.setQuick(columnIndex + i * 2 + 1,openIndexColumn(TableWriter.iFile(path.trimTo(plen),name),mem1,partitionSize,4));
          break;
case ColumnType.BINARY:
        columns.setQuick(columnIndex + i * 2 + 1,openIndexColumn(TableWriter.iFile(path.trimTo(plen),name),mem1,partitionSize,8));
      break;
case ColumnType.LONG:
case ColumnType.DOUBLE:
case ColumnType.DATE:
    mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 8);
  break;
case ColumnType.INT:
case ColumnType.FLOAT:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 4);
break;
case ColumnType.SHORT:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 2);
break;
case ColumnType.BOOLEAN:
case ColumnType.BYTE:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize);
break;
default :
throw CairoException.instance(0).put("String_Node_Str").put(ColumnType.nameOf(metadata.getColumnQuick(i).getType()));
}
columnTops[i]=readColumnTop(ff,path,name,plen);
}
}
}
}
  finally {
path.trimTo(plen);
}
}

Fixed version (ground truth):
private void openPartitionColumns(int columnBase,long partitionSize,long[] columnTops){
  int plen=path.length();
  try {
    for (int i=0; i < columnCount; i++) {
      if (columns.getQuick(getPrimaryColumnIndex(columnBase,i)) == null) {
        String name=metadata.getColumnName(i);
        if (ff.exists(TableWriter.dFile(path.trimTo(plen),name))) {
          ReadOnlyMemory mem1=new ReadOnlyMemory(ff);
          ReadOnlyMemory mem2;
          long offset;
          long len;
          mem1.of(path);
          columns.setQuick(getPrimaryColumnIndex(columnBase,i),mem1);
switch (metadata.getColumnQuick(i).getType()) {
case ColumnType.STRING:
case ColumnType.SYMBOL:
            mem2=new ReadOnlyMemory(ff,TableWriter.iFile(path.trimTo(plen),name),TableWriter.getMapPageSize(ff),partitionSize * 8);
          offset=mem2.getLong((partitionSize - 1) * 8);
        if (ff.read(mem1.getFd(),tempMem8b,4,offset) != 4) {
          throw CairoException.instance(ff.errno()).put("String_Node_Str").put(mem2.getFd()).put("String_Node_Str").put(offset);
        }
      len=Unsafe.getUnsafe().getInt(tempMem8b);
    if (len == -1) {
      mem1.setSize(TableWriter.getMapPageSize(ff),offset + 4);
    }
 else {
      mem1.setSize(TableWriter.getMapPageSize(ff),offset + len + 4);
    }
  columns.setQuick(getSecondaryColumnIndex(columnBase,i),mem2);
break;
case ColumnType.BINARY:
mem2=new ReadOnlyMemory(ff,TableWriter.iFile(path.trimTo(plen),name),TableWriter.getMapPageSize(ff),partitionSize * 8);
offset=mem2.getLong((partitionSize - 1) * 8);
if (ff.read(mem1.getFd(),tempMem8b,8,offset) != 8) {
throw CairoException.instance(ff.errno()).put("String_Node_Str").put(mem2.getFd()).put("String_Node_Str").put(offset);
}
len=Unsafe.getUnsafe().getLong(tempMem8b);
if (len == -1) {
mem1.setSize(TableWriter.getMapPageSize(ff),offset + 8);
}
 else {
mem1.setSize(TableWriter.getMapPageSize(ff),offset + len + 8);
}
columns.setQuick(getSecondaryColumnIndex(columnBase,i),mem2);
break;
case ColumnType.LONG:
case ColumnType.DOUBLE:
case ColumnType.DATE:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 8);
break;
case ColumnType.INT:
case ColumnType.FLOAT:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 4);
break;
case ColumnType.SHORT:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize * 2);
break;
case ColumnType.BOOLEAN:
case ColumnType.BYTE:
mem1.setSize(TableWriter.getMapPageSize(ff),partitionSize);
break;
default :
throw CairoException.instance(0).put("String_Node_Str").put(ColumnType.nameOf(metadata.getColumnQuick(i).getType()));
}
columnTops[i]=readColumnTop(ff,path,name,plen);
}
}
}
}
  finally {
path.trimTo(plen);
}
}