Program: 170765
Project: 170765
Buggy source:
@Override public void readCompleted(DiskManagerReadRequest read_request,DirectByteBuffer buffer){
  complete();
  try {
    this_mon.enter();
    if (stopped) {
      buffer.returnToPool();
      listener.checkCancelled(request);
      return;
    }
    async_checks++;
  }
  finally {
    this_mon.exit();
  }
  if (buffer.getFlag(DirectByteBuffer.FL_CONTAINS_TRANSIENT_DATA)) {
    try {
      buffer.returnToPool();
      listener.checkCompleted(request,false);
    }
  finally {
      try {
        this_mon.enter();
        async_checks--;
        if (stopped) {
          async_check_sem.release();
        }
      }
  finally {
        this_mon.exit();
      }
    }
  }
 else {
    try {
      final DirectByteBuffer f_buffer=buffer;
      ConcurrentHasher.getSingleton().addRequest(buffer.getBuffer(DirectByteBuffer.SS_DW),new ConcurrentHasherRequestListener(){
        @Override public void complete(        ConcurrentHasherRequest hash_request){
          int async_result=3;
          try {
            byte[] actual_hash=hash_request.getResult();
            if (actual_hash != null) {
              request.setHash(actual_hash);
              async_result=1;
              for (int i=0; i < actual_hash.length; i++) {
                if (actual_hash[i] != required_hash[i]) {
                  async_result=2;
                  break;
                }
              }
            }
          }
  finally {
            try {
              if (async_result == 1) {
                try {
                  for (int i=0; i < pieceList.size(); i++) {
                    DMPieceMapEntry piece_entry=pieceList.get(i);
                    DiskManagerFileInfoImpl file_info=piece_entry.getFile();
                    if (file_info.getLength() > 0 || !file_info.isSkipped()) {
                      CacheFile cache_file=file_info.getCacheFile();
                      cache_file.setPieceComplete(pieceNumber,f_buffer);
                    }
                  }
                }
 catch (                Throwable e) {
                  f_buffer.returnToPool();
                  Debug.out(e);
                  listener.checkFailed(request,e);
                  return;
                }
              }
              f_buffer.returnToPool();
              if (async_result == 1) {
                listener.checkCompleted(request,true);
              }
 else               if (async_result == 2) {
                listener.checkCompleted(request,false);
              }
 else {
                listener.checkCancelled(request);
              }
            }
  finally {
              try {
                this_mon.enter();
                async_checks--;
                if (stopped) {
                  async_check_sem.release();
                }
              }
  finally {
                this_mon.exit();
              }
            }
          }
        }
      }
,request.isLowPriority());
    }
 catch (    Throwable e) {
      Debug.printStackTrace(e);
      buffer.returnToPool();
      listener.checkFailed(request,e);
    }
  }
}

Fixed version (ground truth):
@Override public void readCompleted(DiskManagerReadRequest read_request,DirectByteBuffer buffer){
  complete();
  try {
    this_mon.enter();
    if (stopped) {
      buffer.returnToPool();
      listener.checkCancelled(request);
      return;
    }
    async_checks++;
  }
  finally {
    this_mon.exit();
  }
  if (buffer.getFlag(DirectByteBuffer.FL_CONTAINS_TRANSIENT_DATA)) {
    try {
      buffer.returnToPool();
      listener.checkCompleted(request,false);
    }
  finally {
      try {
        this_mon.enter();
        async_checks--;
        if (stopped) {
          async_check_sem.release();
        }
      }
  finally {
        this_mon.exit();
      }
    }
  }
 else {
    try {
      final DirectByteBuffer f_buffer=buffer;
      ConcurrentHasher.getSingleton().addRequest(buffer.getBuffer(DirectByteBuffer.SS_DW),new ConcurrentHasherRequestListener(){
        @Override public void complete(        ConcurrentHasherRequest hash_request){
          int async_result=3;
          try {
            byte[] actual_hash=hash_request.getResult();
            if (actual_hash != null) {
              request.setHash(actual_hash);
              async_result=1;
              for (int i=0; i < actual_hash.length; i++) {
                if (actual_hash[i] != required_hash[i]) {
                  async_result=2;
                  break;
                }
              }
            }
          }
  finally {
            try {
              if (async_result == 1) {
                try {
                  for (int i=0; i < pieceList.size(); i++) {
                    DMPieceMapEntry piece_entry=pieceList.get(i);
                    DiskManagerFileInfoImpl file_info=piece_entry.getFile();
                    if (file_info.getLength() > 0 || !file_info.isSkipped()) {
                      CacheFile cache_file=file_info.getCacheFile();
                      if (!read_flush && file_info.getStorageType() == DiskManagerFileInfoImpl.ST_REORDER) {
                        cache_file.flushCache(piece_entry.getOffset(),piece_entry.getLength());
                      }
                      cache_file.setPieceComplete(pieceNumber,f_buffer);
                    }
                  }
                }
 catch (                Throwable e) {
                  f_buffer.returnToPool();
                  Debug.out(e);
                  listener.checkFailed(request,e);
                  return;
                }
              }
              f_buffer.returnToPool();
              if (async_result == 1) {
                listener.checkCompleted(request,true);
              }
 else               if (async_result == 2) {
                listener.checkCompleted(request,false);
              }
 else {
                listener.checkCancelled(request);
              }
            }
  finally {
              try {
                this_mon.enter();
                async_checks--;
                if (stopped) {
                  async_check_sem.release();
                }
              }
  finally {
                this_mon.exit();
              }
            }
          }
        }
      }
,request.isLowPriority());
    }
 catch (    Throwable e) {
      Debug.printStackTrace(e);
      buffer.returnToPool();
      listener.checkFailed(request,e);
    }
  }
}