Program: 110862
Project: 110862
Buggy source:
@Override public void exec(Spawn spawn,ActionExecutionContext actionExecutionContext,AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
  Executor executor=actionExecutionContext.getExecutor();
  if (!spawn.isRemotable() || spawn.hasNoSandbox()) {
    SandboxHelpers.fallbackToNonSandboxedExecution(spawn,actionExecutionContext,executor);
    return;
  }
  SandboxHelpers.reportSubcommand(executor,spawn);
  SandboxHelpers.postActionStatusMessage(executor,spawn);
  PrintWriter errWriter=sandboxDebug ? new PrintWriter(actionExecutionContext.getFileOutErr().getErrorStream()) : null;
  Path sandboxPath=SandboxHelpers.getSandboxRoot(blazeDirs,productName,uuid,execCounter);
  Path sandboxExecRoot=sandboxPath.getRelative("String_Node_Str").getRelative(execRoot.getBaseName());
  if (errWriter != null) {
    errWriter.printf("String_Node_Str",sandboxPath.toString());
    errWriter.printf("String_Node_Str",sandboxExecRoot.toString());
  }
  ImmutableMap<String,String> spawnEnvironment=StandaloneSpawnStrategy.locallyDeterminedEnv(execRoot,productName,spawn.getEnvironment());
  Set<Path> writableDirs=getWritableDirs(sandboxExecRoot,spawn.getEnvironment());
  Path runUnderPath=getRunUnderPath(spawn);
  try {
    HardlinkedExecRoot hardlinkedExecRoot=new HardlinkedExecRoot(execRoot,sandboxPath,sandboxExecRoot,errWriter);
    ImmutableSet<PathFragment> outputs=SandboxHelpers.getOutputFiles(spawn);
    hardlinkedExecRoot.createFileSystem(getMounts(spawn,actionExecutionContext),outputs,writableDirs);
    if (errWriter != null) {
      errWriter.flush();
    }
    DarwinSandboxRunner runner;
    runner=new DarwinSandboxRunner(sandboxPath,sandboxExecRoot,getWritableDirs(sandboxExecRoot,spawnEnvironment),getInaccessiblePaths(),runUnderPath,verboseFailures);
    try {
      runner.run(spawn.getArguments(),spawnEnvironment,actionExecutionContext.getFileOutErr(),Spawns.getTimeoutSeconds(spawn),SandboxHelpers.shouldAllowNetwork(buildRequest,spawn));
    }
  finally {
      if (writeOutputFiles != null && !writeOutputFiles.compareAndSet(null,DarwinSandboxedStrategy.class)) {
        Thread.currentThread().interrupt();
      }
 else {
        hardlinkedExecRoot.copyOutputs(execRoot,outputs);
      }
      if (!sandboxDebug) {
        SandboxHelpers.lazyCleanup(backgroundWorkers,runner);
      }
    }
  }
 catch (  IOException e) {
    throw new UserExecException("String_Node_Str",e);
  }
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
}

Fixed version (ground truth):
@Override public void exec(Spawn spawn,ActionExecutionContext actionExecutionContext,AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
  Executor executor=actionExecutionContext.getExecutor();
  if (!spawn.isRemotable() || spawn.hasNoSandbox()) {
    SandboxHelpers.fallbackToNonSandboxedExecution(spawn,actionExecutionContext,executor);
    return;
  }
  SandboxHelpers.reportSubcommand(executor,spawn);
  SandboxHelpers.postActionStatusMessage(executor,spawn);
  PrintWriter errWriter=sandboxDebug ? new PrintWriter(actionExecutionContext.getFileOutErr().getErrorStream()) : null;
  Path sandboxPath=SandboxHelpers.getSandboxRoot(blazeDirs,productName,uuid,execCounter);
  Path sandboxExecRoot=sandboxPath.getRelative("String_Node_Str").getRelative(execRoot.getBaseName());
  if (errWriter != null) {
    errWriter.printf("String_Node_Str",sandboxPath.toString());
    errWriter.printf("String_Node_Str",sandboxExecRoot.toString());
  }
  ImmutableMap<String,String> spawnEnvironment=StandaloneSpawnStrategy.locallyDeterminedEnv(execRoot,productName,spawn.getEnvironment());
  Set<Path> writableDirs=getWritableDirs(sandboxExecRoot,spawn.getEnvironment());
  Path runUnderPath=getRunUnderPath(spawn);
  HardlinkedExecRoot hardlinkedExecRoot=new HardlinkedExecRoot(execRoot,sandboxPath,sandboxExecRoot,errWriter);
  ImmutableSet<PathFragment> outputs=SandboxHelpers.getOutputFiles(spawn);
  try {
    hardlinkedExecRoot.createFileSystem(getMounts(spawn,actionExecutionContext),outputs,writableDirs);
  }
 catch (  IOException e) {
    throw new UserExecException("String_Node_Str",e);
  }
  if (errWriter != null) {
    errWriter.flush();
  }
  DarwinSandboxRunner runner=new DarwinSandboxRunner(sandboxPath,sandboxExecRoot,getWritableDirs(sandboxExecRoot,spawnEnvironment),getInaccessiblePaths(),runUnderPath,verboseFailures);
  runSpawn(spawn,actionExecutionContext,spawnEnvironment,hardlinkedExecRoot,outputs,runner,writeOutputFiles);
}