Program: 30814
Project: 30814
Buggy source:
public BitmapIndexWriter(CairoConfiguration configuration,CharSequence name,int blockCapacity){
  long pageSize=configuration.getFilesFacade().getMapPageSize();
  try (Path path=new Path()){
    BitmapIndexUtils.keyFileName(path,configuration.getRoot(),name);
    boolean exists=configuration.getFilesFacade().exists(path);
    this.keyMem=new ReadWriteMemory(configuration.getFilesFacade(),path,pageSize);
    if (!exists) {
      initKeyMemory(blockCapacity);
    }
    long keyMemSize=this.keyMem.getAppendOffset();
    if (keyMemSize < BitmapIndexUtils.KEY_FILE_RESERVED) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    if (this.keyMem.getByte(BitmapIndexUtils.KEY_RESERVED_OFFSET_SIGNATURE) != BitmapIndexUtils.SIGNATURE) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.keyCount=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_KEY_COUNT);
    if (keyMemSize != keyMemSize()) {
      LOG.error().$("String_Node_Str").$(path).$("String_Node_Str").$(this.keyCount).$(']').$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    if (this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK) != this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE)) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.valueMemSize=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_VALUE_MEM_SIZE);
    BitmapIndexUtils.valueFileName(path,configuration.getRoot(),name);
    this.valueMem=new ReadWriteMemory(configuration.getFilesFacade(),path,pageSize);
    if (this.valueMem.getAppendOffset() != this.valueMemSize) {
      LOG.error().$("String_Node_Str").$(path).$("String_Node_Str").$(this.valueMemSize).$(']').$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.blockValueCountMod=this.keyMem.getInt(BitmapIndexUtils.KEY_RESERVED_OFFSET_BLOCK_VALUE_COUNT) - 1;
    this.blockCapacity=(this.blockValueCountMod + 1) * 8 + BitmapIndexUtils.VALUE_BLOCK_FILE_RESERVED;
  }
 catch (  CairoException e) {
    this.close();
    throw e;
  }
}

Fixed version (ground truth):
public BitmapIndexWriter(CairoConfiguration configuration,CharSequence name,int valueBlockCapacity){
  long pageSize=configuration.getFilesFacade().getMapPageSize();
  try (Path path=new Path()){
    BitmapIndexUtils.keyFileName(path,configuration.getRoot(),name);
    boolean exists=configuration.getFilesFacade().exists(path);
    this.keyMem=new ReadWriteMemory(configuration.getFilesFacade(),path,pageSize);
    if (!exists) {
      initKeyMemory(valueBlockCapacity);
    }
    long keyMemSize=this.keyMem.getAppendOffset();
    if (keyMemSize < BitmapIndexUtils.KEY_FILE_RESERVED) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    if (this.keyMem.getByte(BitmapIndexUtils.KEY_RESERVED_OFFSET_SIGNATURE) != BitmapIndexUtils.SIGNATURE) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.keyCount=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_KEY_COUNT);
    if (keyMemSize != keyMemSize()) {
      LOG.error().$("String_Node_Str").$(path).$("String_Node_Str").$(this.keyCount).$(']').$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    if (this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK) != this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE)) {
      LOG.error().$("String_Node_Str").$(path).$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.valueMemSize=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_VALUE_MEM_SIZE);
    BitmapIndexUtils.valueFileName(path,configuration.getRoot(),name);
    this.valueMem=new ReadWriteMemory(configuration.getFilesFacade(),path,pageSize);
    if (this.valueMem.getAppendOffset() != this.valueMemSize) {
      LOG.error().$("String_Node_Str").$(path).$("String_Node_Str").$(this.valueMemSize).$(']').$();
      throw CairoException.instance(0).put("String_Node_Str").put(path);
    }
    this.blockValueCountMod=this.keyMem.getInt(BitmapIndexUtils.KEY_RESERVED_OFFSET_BLOCK_VALUE_COUNT) - 1;
    this.blockCapacity=(this.blockValueCountMod + 1) * 8 + BitmapIndexUtils.VALUE_BLOCK_FILE_RESERVED;
  }
 catch (  CairoException e) {
    this.close();
    throw e;
  }
}