Program: 38868
Project: 38868
Buggy source:
MpiJobSchedulerImpl(MpiNativeServices nativeServices,MpiStatistics statistics,final int coresPerRank,boolean verbose,ExecutorService executor,Path stdOutArchive) throws InterruptedException, IOException {
  this.nativeServices=Objects.requireNonNull(nativeServices);
  this.statistics=Objects.requireNonNull(statistics);
  if (stdOutArchive != null) {
    if (Files.exists(stdOutArchive)) {
      if (!Files.isRegularFile(stdOutArchive)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      Files.deleteIfExists(stdOutArchive);
    }
    LOGGER.info("String_Node_Str",stdOutArchive);
  }
  this.stdOutArchive=stdOutArchive;
  final CountDownLatch initialized=new CountDownLatch(1);
  future=executor.submit(new Runnable(){
    @Override public void run(){
      LOGGER.trace("String_Node_Str");
      try {
        nativeServices.initMpi(coresPerRank,verbose);
        mpiVersion=nativeServices.getMpiVersion();
        resources=new MpiResources(nativeServices.getMpiCommSize(),coresPerRank);
        initialized.countDown();
        long time=System.currentTimeMillis();
        List<MpiTask> completedTasks=new ArrayList<>();
        while (!stopRequested || !jobs.isEmpty()) {
          boolean sleep=true;
          long oldTime=time;
          time=System.currentTimeMillis();
          long diff=time - oldTime;
          if (diff > 1000) {
            LOGGER.warn("String_Node_Str",diff,startTasksTime,startTasksJniTime,processCompletedTasksTime,checkTaskCompletionTime);
          }
          startTasksTime=0;
          startTasksJniTime=0;
          processCompletedTasksTime=0;
          checkTaskCompletionTime=0;
          newCommonFileLock.lock();
          try {
            for (            CommonFile commonFile : newCommonFiles) {
              LOGGER.info("String_Node_Str",commonFile.getChunk(),commonFile.getName(),commonFile.isLast());
              List<Core> allCores=resources.reserveAllCoresOrFail();
              try {
                try (ByteArrayInputStream is=new ByteArrayInputStream(commonFile.getData())){
                  Messages.CommonFile message=Messages.CommonFile.newBuilder().setName(commonFile.getName()).setChunk(commonFile.getChunk()).setLast(commonFile.isLast()).setData(ByteString.readFrom(is)).build();
                  long t1=System.currentTimeMillis();
                  nativeServices.sendCommonFile(message.toByteArray());
                  long t2=System.currentTimeMillis();
                  commonFiles.add(commonFile.getName());
                  MpiJobSchedulerImpl.this.statistics.logCommonFileTransfer(commonFile.getName(),commonFile.getChunk(),commonFile.getData().length,t2 - t1);
                }
               }
  finally {
                resources.releaseCores(allCores);
              }
            }
            newCommonFiles.clear();
          }
  finally {
            newCommonFileLock.unlock();
          }
          newJobsLock.lock();
          try {
            jobs.addAll(newJobs);
            newJobs.clear();
          }
  finally {
            newJobsLock.unlock();
          }
          for (Iterator<MpiJob> it=jobs.iterator(); it.hasNext(); ) {
            MpiJob job=it.next();
            sleep=startTasks(job);
            long t0=System.currentTimeMillis();
            try {
              nativeServices.checkTasksCompletion(job.getRunningTasks(),completedTasks);
            }
  finally {
              checkTaskCompletionTime+=System.currentTimeMillis() - t0;
            }
            if (!completedTasks.isEmpty()) {
              DateTime endTime=DateTime.now();
              for (              MpiTask tasks : completedTasks) {
                MpiJobSchedulerImpl.this.resources.releaseCore(tasks.getCore());
                tasks.setEndTime(endTime);
              }
              startTasks(job);
              processCompletedTasks(job,completedTasks);
              if (job.isCompleted()) {
                it.remove();
                ExecutionReport report=new ExecutionReport(job.getErrors());
                try {
                  job.getListener().onEnd(report);
                }
 catch (                Exception e) {
                  LOGGER.error(e.toString(),e);
                }
                job.getFuture().complete(report);
                MpiJobSchedulerImpl.this.statistics.logJobEnd(job.getId());
              }
              sleep=false;
            }
          }
          if (sleep) {
            TimeUnit.MILLISECONDS.sleep(TIMEOUT);
          }
        }
        nativeServices.terminateMpi();
      }
 catch (      Throwable t) {
        LOGGER.error(t.toString(),t);
        System.exit(-1);
      }
      LOGGER.trace("String_Node_Str");
    }
  }
);
  initialized.await();
}

Fixed version (ground truth):
MpiJobSchedulerImpl(MpiNativeServices nativeServices,MpiStatisticsFactory statisticsFactory,Path statisticsDbDir,String statisticsDbName,int coresPerRank,boolean verbose,ExecutorService executor,Path stdOutArchive) throws InterruptedException, IOException {
  this.nativeServices=Objects.requireNonNull(nativeServices);
  this.statistics=Objects.requireNonNull(statisticsFactory).create(statisticsDbDir,statisticsDbName);
  if (stdOutArchive != null) {
    if (Files.exists(stdOutArchive)) {
      if (!Files.isRegularFile(stdOutArchive)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      Files.deleteIfExists(stdOutArchive);
    }
    LOGGER.info("String_Node_Str",stdOutArchive);
  }
  this.stdOutArchive=stdOutArchive;
  final CountDownLatch initialized=new CountDownLatch(1);
  future=executor.submit(new Runnable(){
    @Override public void run(){
      LOGGER.trace("String_Node_Str");
      try {
        nativeServices.initMpi(coresPerRank,verbose);
        mpiVersion=nativeServices.getMpiVersion();
        resources=new MpiResources(nativeServices.getMpiCommSize(),coresPerRank);
        initialized.countDown();
        long time=System.currentTimeMillis();
        List<MpiTask> completedTasks=new ArrayList<>();
        while (!stopRequested || !jobs.isEmpty()) {
          boolean sleep=true;
          long oldTime=time;
          time=System.currentTimeMillis();
          long diff=time - oldTime;
          if (diff > 1000) {
            LOGGER.warn("String_Node_Str",diff,startTasksTime,startTasksJniTime,processCompletedTasksTime,checkTaskCompletionTime);
          }
          startTasksTime=0;
          startTasksJniTime=0;
          processCompletedTasksTime=0;
          checkTaskCompletionTime=0;
          newCommonFileLock.lock();
          try {
            for (            CommonFile commonFile : newCommonFiles) {
              LOGGER.info("String_Node_Str",commonFile.getChunk(),commonFile.getName(),commonFile.isLast());
              List<Core> allCores=resources.reserveAllCoresOrFail();
              try {
                try (ByteArrayInputStream is=new ByteArrayInputStream(commonFile.getData())){
                  Messages.CommonFile message=Messages.CommonFile.newBuilder().setName(commonFile.getName()).setChunk(commonFile.getChunk()).setLast(commonFile.isLast()).setData(ByteString.readFrom(is)).build();
                  long t1=System.currentTimeMillis();
                  nativeServices.sendCommonFile(message.toByteArray());
                  long t2=System.currentTimeMillis();
                  commonFiles.add(commonFile.getName());
                  MpiJobSchedulerImpl.this.statistics.logCommonFileTransfer(commonFile.getName(),commonFile.getChunk(),commonFile.getData().length,t2 - t1);
                }
               }
  finally {
                resources.releaseCores(allCores);
              }
            }
            newCommonFiles.clear();
          }
  finally {
            newCommonFileLock.unlock();
          }
          newJobsLock.lock();
          try {
            jobs.addAll(newJobs);
            newJobs.clear();
          }
  finally {
            newJobsLock.unlock();
          }
          for (Iterator<MpiJob> it=jobs.iterator(); it.hasNext(); ) {
            MpiJob job=it.next();
            sleep=startTasks(job);
            long t0=System.currentTimeMillis();
            try {
              nativeServices.checkTasksCompletion(job.getRunningTasks(),completedTasks);
            }
  finally {
              checkTaskCompletionTime+=System.currentTimeMillis() - t0;
            }
            if (!completedTasks.isEmpty()) {
              DateTime endTime=DateTime.now();
              for (              MpiTask tasks : completedTasks) {
                MpiJobSchedulerImpl.this.resources.releaseCore(tasks.getCore());
                tasks.setEndTime(endTime);
              }
              startTasks(job);
              processCompletedTasks(job,completedTasks);
              if (job.isCompleted()) {
                it.remove();
                ExecutionReport report=new ExecutionReport(job.getErrors());
                try {
                  job.getListener().onEnd(report);
                }
 catch (                Exception e) {
                  LOGGER.error(e.toString(),e);
                }
                job.getFuture().complete(report);
                MpiJobSchedulerImpl.this.statistics.logJobEnd(job.getId());
              }
              sleep=false;
            }
          }
          if (sleep) {
            TimeUnit.MILLISECONDS.sleep(TIMEOUT);
          }
        }
        nativeServices.terminateMpi();
      }
 catch (      Throwable t) {
        LOGGER.error(t.toString(),t);
        System.exit(-1);
      }
      LOGGER.trace("String_Node_Str");
    }
  }
);
  initialized.await();
}