Program: 180394
Project: 180394
Buggy source:
private void saveDataBlock(DataBlock<Trajectory> trajectories,int lengthLimit,boolean lengthLimitIsNeeded){
  if (trajectories == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int dimension=trajectories.getTrajectory(0).getLength();
  int length=lengthLimitIsNeeded ? lengthLimit : Math.min(getMaxDataBlockLength(trajectories),lengthLimit);
  if (!isInitialized() || trajectories.size() > hostLengths.length || trajectories.size() * length > hostTimes.length || trajectories.size() * length * dimension > hostPoints.length) {
    free();
    initialize(trajectories.size(),length,dimension);
  }
  int trajectoryIndex=0;
  int pointIndex;
  for (  Trajectory trajectory : trajectories) {
    if (dimension != trajectory.getDimension()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    hostLengths[trajectoryIndex]=trajectory.getLength();
    pointIndex=0;
    for (    Point point : trajectory) {
      if (pointIndex >= lengthLimit) {
        break;
      }
      for (int dim=0; dim < point.getDimension(); dim++) {
        System.arraycopy(point.toArray(),0,hostPoints,pointIndex * trajectories.size() * dimension + trajectoryIndex * dimension,point.getDimension());
        hostTimes[pointIndex * trajectories.size() + trajectoryIndex]=point.getTime();
      }
    }
    trajectoryIndex++;
  }
  Utils.checkErrorCode(JCuda.cudaMemcpy(devicePoints,Pointer.to(hostPoints),trajectories.size() * length * dimension* Sizeof.FLOAT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  Utils.checkErrorCode(JCuda.cudaMemcpy(deviceTimes,Pointer.to(hostTimes),trajectories.size() * length * Sizeof.FLOAT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  Utils.checkErrorCode(JCuda.cudaMemcpy(deviceLengths,Pointer.to(hostLengths),trajectories.size() * Sizeof.INT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  savedDataBlock=trajectories;
}

Fixed version (ground truth):
private void saveDataBlock(DataBlock<Trajectory> trajectories,int lengthLimit,boolean lengthLimitIsNeeded){
  if (trajectories == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int dimension=trajectories.getTrajectory(0).getDimension();
  int length=lengthLimitIsNeeded ? lengthLimit : Math.min(getMaxDataBlockLength(trajectories),lengthLimit);
  if (!isInitialized() || trajectories.size() > hostLengths.length || trajectories.size() * length > hostTimes.length || trajectories.size() * length * dimension > hostPoints.length) {
    free();
    initialize(trajectories.size(),length,dimension);
  }
  int trajectoryIndex=0;
  int pointIndex;
  for (  Trajectory trajectory : trajectories) {
    if (dimension != trajectory.getDimension()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    hostLengths[trajectoryIndex]=trajectory.getLength();
    pointIndex=0;
    for (    Point point : trajectory) {
      if (pointIndex >= lengthLimit) {
        break;
      }
      System.out.println("String_Node_Str" + pointIndex + "String_Node_Str"+ trajectoryIndex+ "String_Node_Str"+ (pointIndex * trajectories.size() * dimension + trajectoryIndex * dimension));
      System.arraycopy(point.toArray(),0,hostPoints,pointIndex * trajectories.size() * dimension + trajectoryIndex * dimension,dimension);
      hostTimes[pointIndex * trajectories.size() + trajectoryIndex]=point.getTime();
      pointIndex++;
    }
    trajectoryIndex++;
  }
  Utils.checkErrorCode(JCuda.cudaMemcpy(devicePoints,Pointer.to(hostPoints),trajectories.size() * length * dimension* Sizeof.FLOAT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  Utils.checkErrorCode(JCuda.cudaMemcpy(deviceTimes,Pointer.to(hostTimes),trajectories.size() * length * Sizeof.FLOAT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  Utils.checkErrorCode(JCuda.cudaMemcpy(deviceLengths,Pointer.to(hostLengths),trajectories.size() * Sizeof.INT,cudaMemcpyKind.cudaMemcpyHostToDevice));
  savedDataBlock=trajectories;
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
}