Program: 52835
Project: 52835
Buggy source:
private void performStampedeDistributedBuild(DistBuildService distBuildService,CommandRunnerParams params,DistBuildConfig distBuildConfig,ListeningExecutorService executorService,ProjectFilesystem filesystem,FileHashCache fileHashCache,BuildEvent.DistBuildStarted started,Object distributedBuildExitCodeLock,AtomicReference<StampedeId> stampedeIdReference,AtomicInteger distributedBuildExitCode,CountDownLatch localBuildInitializationLatch,AtomicInteger localBuildExitCode,RemoteBuildRuleSynchronizer remoteBuildSynchronizer,BuildController build){
  int exitCode=com.facebook.buck.distributed.ExitCode.DISTRIBUTED_PENDING_EXIT_CODE.getCode();
  try {
    BuildController.ExecutionResult distBuildResult=build.executeAndPrintFailuresToEventBus(executorService,filesystem,fileHashCache,params.getBuckEventBus(),params.getInvocationInfo().get(),distBuildConfig.getBuildMode(),distBuildConfig.getNumberOfMinions(),distBuildConfig.getRepository(),distBuildConfig.getTenantId(),localRuleKeyCalculator);
    exitCode=distBuildResult.exitCode;
    if (exitCode == com.facebook.buck.distributed.ExitCode.DISTRIBUTED_BUILD_STEP_LOCAL_EXCEPTION.getCode()) {
      LOG.warn("String_Node_Str");
      terminateStampedeBuild(distBuildService,Preconditions.checkNotNull(stampedeIdReference.get()),BuildStatus.FAILED,"String_Node_Str");
    }
    String finishedMessage=String.format("String_Node_Str",exitCode);
    if (exitCode == 0 || localBuildExitCode.get() == 0) {
      params.getConsole().printSuccess(finishedMessage);
    }
 else {
      params.getConsole().printErrorText(finishedMessage);
    }
    if (exitCode != 0 && !distBuildConfig.isSlowLocalBuildFallbackModeEnabled() && !distBuildConfig.shouldAlwaysWaitForRemoteBuildBeforeProceedingLocally()) {
      localBuildInitializationLatch.await();
      String message="String_Node_Str";
      LOG.warn(message);
      Preconditions.checkNotNull(lastBuild).terminateBuildWithFailure(new Exception(message));
    }
    if (exitCode != 0 && (distBuildConfig.isSlowLocalBuildFallbackModeEnabled() || distBuildConfig.shouldAlwaysWaitForRemoteBuildBeforeProceedingLocally())) {
      String errorMessage=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",distBuildResult.stampedeId,exitCode,Joiner.on("String_Node_Str").join(arguments),distBuildConfig.isSlowLocalBuildFallbackModeEnabled(),distBuildConfig.shouldAlwaysWaitForRemoteBuildBeforeProceedingLocally());
      params.getConsole().printErrorText(errorMessage);
      LOG.error(errorMessage);
    }
  }
 catch (  IOException e) {
    LOG.error(e,"String_Node_Str");
    throw new RuntimeException(e);
  }
catch (  InterruptedException e) {
    LOG.warn(e,"String_Node_Str");
    Thread.currentThread().interrupt();
    return;
  }
 finally {
synchronized (distributedBuildExitCodeLock) {
      if (distributedBuildExitCode.get() == com.facebook.buck.distributed.ExitCode.DISTRIBUTED_PENDING_EXIT_CODE.getCode()) {
        distributedBuildExitCode.set(exitCode);
      }
    }
    remoteBuildSynchronizer.signalCompletionOfRemoteBuild();
    BuildEvent.DistBuildFinished finished=BuildEvent.distBuildFinished(Preconditions.checkNotNull(started),ExitCode.map(exitCode));
    params.getBuckEventBus().post(finished);
  }
}

Fixed version (ground truth):
private void performStampedeDistributedBuild(DistBuildService distBuildService,CommandRunnerParams params,DistBuildConfig distBuildConfig,ListeningExecutorService executorService,ProjectFilesystem filesystem,FileHashCache fileHashCache,BuildEvent.DistBuildStarted started,Object distributedBuildExitCodeLock,AtomicReference<StampedeId> stampedeIdReference,AtomicInteger distributedBuildExitCode,CountDownLatch localBuildInitializationLatch,AtomicInteger localBuildExitCode,RemoteBuildRuleSynchronizer remoteBuildSynchronizer,BuildController build){
  int exitCode=com.facebook.buck.distributed.ExitCode.DISTRIBUTED_PENDING_EXIT_CODE.getCode();
  try {
    BuildController.ExecutionResult distBuildResult=build.executeAndPrintFailuresToEventBus(executorService,filesystem,fileHashCache,params.getBuckEventBus(),params.getInvocationInfo().get(),distBuildConfig.getBuildMode(),distBuildConfig.getNumberOfMinions(),distBuildConfig.getRepository(),distBuildConfig.getTenantId(),localRuleKeyCalculator);
    exitCode=distBuildResult.exitCode;
    if (exitCode == com.facebook.buck.distributed.ExitCode.DISTRIBUTED_BUILD_STEP_LOCAL_EXCEPTION.getCode()) {
      LOG.warn("String_Node_Str");
      terminateStampedeBuild(distBuildService,Preconditions.checkNotNull(stampedeIdReference.get()),BuildStatus.FAILED,"String_Node_Str");
    }
    String finishedMessage=String.format("String_Node_Str",exitCode);
    if (exitCode == 0 || localBuildExitCode.get() == 0) {
      params.getConsole().printSuccess(finishedMessage);
    }
 else {
      params.getConsole().printErrorText(finishedMessage);
    }
    if (exitCode != 0) {
      if (!distBuildConfig.isSlowLocalBuildFallbackModeEnabled()) {
        localBuildInitializationLatch.await();
        String message="String_Node_Str";
        LOG.warn(message);
        Preconditions.checkNotNull(lastBuild).terminateBuildWithFailure(new Exception(message));
      }
 else {
        String errorMessage=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",distBuildResult.stampedeId,exitCode,Joiner.on("String_Node_Str").join(arguments),distBuildConfig.isSlowLocalBuildFallbackModeEnabled());
        params.getConsole().printErrorText(errorMessage);
        LOG.error(errorMessage);
      }
    }
  }
 catch (  IOException e) {
    LOG.error(e,"String_Node_Str");
    throw new RuntimeException(e);
  }
catch (  InterruptedException e) {
    LOG.warn(e,"String_Node_Str");
    Thread.currentThread().interrupt();
    return;
  }
 finally {
synchronized (distributedBuildExitCodeLock) {
      if (distributedBuildExitCode.get() == com.facebook.buck.distributed.ExitCode.DISTRIBUTED_PENDING_EXIT_CODE.getCode()) {
        distributedBuildExitCode.set(exitCode);
      }
    }
    remoteBuildSynchronizer.signalCompletionOfRemoteBuild();
    BuildEvent.DistBuildFinished finished=BuildEvent.distBuildFinished(Preconditions.checkNotNull(started),ExitCode.map(exitCode));
    params.getBuckEventBus().post(finished);
  }
}