Program: 111017
Project: 111017
Buggy source:
@Override public ExitCode exec(BlazeRuntime runtime,OptionsProvider options){
  RunOptions runOptions=options.getOptions(RunOptions.class);
  List<String> targetAndArgs=options.getResidue();
  if (targetAndArgs.isEmpty()) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  String targetString=targetAndArgs.get(0);
  List<String> runTargetArgs=targetAndArgs.subList(1,targetAndArgs.size());
  RunUnder runUnder=options.getOptions(BuildConfiguration.Options.class).runUnder;
  OutErr outErr=runtime.getReporter().getOutErr();
  List<String> targets=(runUnder != null) && (runUnder.getLabel() != null) ? ImmutableList.of(targetString,runUnder.getLabel().toString()) : ImmutableList.of(targetString);
  BuildRequest request=BuildRequest.create(this.getClass().getAnnotation(Command.class).name(),options,runtime.getStartupOptionsProvider(),targets,outErr,runtime.getCommandId(),runtime.getCommandStartTime());
  currentRunUnder=runUnder;
  BuildResult result;
  try {
    result=processRequest(runtime,request);
  }
  finally {
    currentRunUnder=null;
  }
  if (!result.getSuccess()) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return result.getExitCondition();
  }
  Collection<ConfiguredTarget> targetsBuilt=result.getSuccessfulTargets();
  ConfiguredTarget targetToRun=null;
  ConfiguredTarget runUnderTarget=null;
  if (targetsBuilt != null) {
    int maxTargets=runUnder != null && runUnder.getLabel() != null ? 2 : 1;
    if (targetsBuilt.size() > maxTargets) {
      runtime.getReporter().handle(Event.error(SINGLE_TARGET_MESSAGE));
      return ExitCode.COMMAND_LINE_ERROR;
    }
    for (    ConfiguredTarget target : targetsBuilt) {
      ExitCode targetValidation=fullyValidateTarget(runtime,target);
      if (targetValidation != ExitCode.SUCCESS) {
        return targetValidation;
      }
      if (runUnder != null && target.getLabel().equals(runUnder.getLabel())) {
        if (runUnderTarget != null) {
          runtime.getReporter().handle(Event.error(null,"String_Node_Str"));
          return ExitCode.COMMAND_LINE_ERROR;
        }
        runUnderTarget=target;
      }
 else       if (targetToRun == null) {
        targetToRun=target;
      }
 else {
        runtime.getReporter().handle(Event.error(SINGLE_TARGET_MESSAGE));
        return ExitCode.COMMAND_LINE_ERROR;
      }
    }
  }
  if ((targetToRun == null) && (runUnderTarget != null)) {
    targetToRun=runUnderTarget;
  }
  if (targetToRun == null) {
    runtime.getReporter().handle(Event.error(NO_TARGET_MESSAGE));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  Path executablePath=Preconditions.checkNotNull(targetToRun.getProvider(FilesToRunProvider.class).getExecutable().getPath());
  BuildConfiguration configuration=targetToRun.getConfiguration();
  if (configuration == null) {
    configuration=runtime.getBuildTool().getView().getConfigurationCollection().getTargetConfigurations().get(0);
  }
  Path workingDir;
  try {
    workingDir=ensureRunfilesBuilt(runtime,targetToRun);
  }
 catch (  CommandException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.LOCAL_ENVIRONMENTAL_ERROR;
  }
  List<String> args=runTargetArgs;
  FilesToRunProvider provider=targetToRun.getProvider(FilesToRunProvider.class);
  RunfilesSupport runfilesSupport=provider == null ? null : provider.getRunfilesSupport();
  if (runfilesSupport != null && runfilesSupport.getArgs() != null) {
    List<String> targetArgs=runfilesSupport.getArgs();
    if (!targetArgs.isEmpty()) {
      args=Lists.newArrayListWithCapacity(targetArgs.size() + runTargetArgs.size());
      args.addAll(targetArgs);
      args.addAll(runTargetArgs);
    }
  }
  PathFragment prettyExecutablePath=OutputDirectoryLinksUtils.getPrettyPath(executablePath,runtime.getWorkspaceName(),runtime.getWorkspace(),options.getOptions(BuildRequestOptions.class).symlinkPrefix);
  List<String> cmdLine=new ArrayList<>();
  if (runOptions.scriptPath == null) {
    cmdLine.add(runtime.getDirectories().getExecRoot().getRelative(runtime.getBinTools().getExecPath(PROCESS_WRAPPER)).getPathString());
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
  }
  List<String> prettyCmdLine=new ArrayList<>();
  if (runUnder != null) {
    String runUnderValue=runUnder.getValue();
    if (runUnderTarget != null) {
      runUnderValue=runUnderTarget.getProvider(FilesToRunProvider.class).getExecutable().getPath().getPathString();
      List<String> opts=runUnder.getOptions();
      if (!opts.isEmpty()) {
        runUnderValue+="String_Node_Str" + ShellEscaper.escapeJoinAll(opts);
      }
    }
    cmdLine.add(configuration.getShExecutable().getPathString());
    cmdLine.add("String_Node_Str");
    cmdLine.add(runUnderValue + "String_Node_Str" + executablePath.getPathString()+ "String_Node_Str"+ ShellEscaper.escapeJoinAll(args));
    prettyCmdLine.add(configuration.getShExecutable().getPathString());
    prettyCmdLine.add("String_Node_Str");
    prettyCmdLine.add(runUnderValue + "String_Node_Str" + prettyExecutablePath.getPathString()+ "String_Node_Str"+ ShellEscaper.escapeJoinAll(args));
  }
 else {
    cmdLine.add(executablePath.getPathString());
    cmdLine.addAll(args);
    prettyCmdLine.add(prettyExecutablePath.getPathString());
    prettyCmdLine.addAll(args);
  }
  outErr.printErrLn("String_Node_Str");
  if (runOptions.scriptPath != null) {
    String unisolatedCommand=CommandFailureUtils.describeCommand(CommandDescriptionForm.COMPLETE_UNISOLATED,cmdLine,null,workingDir.getPathString());
    if (writeScript(runtime,runOptions.scriptPath,unisolatedCommand)) {
      return ExitCode.SUCCESS;
    }
 else {
      return ExitCode.RUN_FAILURE;
    }
  }
  runtime.getReporter().handle(Event.info(null,"String_Node_Str" + ShellEscaper.escapeJoinAll(prettyCmdLine)));
  com.google.devtools.build.lib.shell.Command command=new CommandBuilder().addArgs(cmdLine).setEnv(runtime.getClientEnv()).setWorkingDir(workingDir).build();
  try {
    command.execute(com.google.devtools.build.lib.shell.Command.NO_INPUT,com.google.devtools.build.lib.shell.Command.NO_OBSERVER,outErr.getOutputStream(),outErr.getErrorStream(),true).getTerminationStatus().getExitCode();
    return ExitCode.SUCCESS;
  }
 catch (  BadExitStatusException e) {
    String message="String_Node_Str" + e.getResult().getTerminationStatus().getExitCode() + "String_Node_Str"+ e.getMessage();
    runtime.getReporter().handle(Event.error(message));
    return ExitCode.RUN_FAILURE;
  }
catch (  AbnormalTerminationException e) {
    return ExitCode.INTERRUPTED;
  }
catch (  CommandException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.RUN_FAILURE;
  }
}

Fixed version (ground truth):
@Override public ExitCode exec(BlazeRuntime runtime,OptionsProvider options){
  RunOptions runOptions=options.getOptions(RunOptions.class);
  List<String> targetAndArgs=options.getResidue();
  if (targetAndArgs.isEmpty()) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  String targetString=targetAndArgs.get(0);
  List<String> runTargetArgs=targetAndArgs.subList(1,targetAndArgs.size());
  RunUnder runUnder=options.getOptions(BuildConfiguration.Options.class).runUnder;
  OutErr outErr=runtime.getReporter().getOutErr();
  List<String> targets=(runUnder != null) && (runUnder.getLabel() != null) ? ImmutableList.of(targetString,runUnder.getLabel().toString()) : ImmutableList.of(targetString);
  BuildRequest request=BuildRequest.create(this.getClass().getAnnotation(Command.class).name(),options,runtime.getStartupOptionsProvider(),targets,outErr,runtime.getCommandId(),runtime.getCommandStartTime());
  currentRunUnder=runUnder;
  BuildResult result;
  try {
    result=processRequest(runtime,request);
  }
  finally {
    currentRunUnder=null;
  }
  if (!result.getSuccess()) {
    runtime.getReporter().handle(Event.error("String_Node_Str"));
    return result.getExitCondition();
  }
  Collection<ConfiguredTarget> targetsBuilt=result.getSuccessfulTargets();
  ConfiguredTarget targetToRun=null;
  ConfiguredTarget runUnderTarget=null;
  if (targetsBuilt != null) {
    int maxTargets=runUnder != null && runUnder.getLabel() != null ? 2 : 1;
    if (targetsBuilt.size() > maxTargets) {
      runtime.getReporter().handle(Event.error(SINGLE_TARGET_MESSAGE));
      return ExitCode.COMMAND_LINE_ERROR;
    }
    for (    ConfiguredTarget target : targetsBuilt) {
      ExitCode targetValidation=fullyValidateTarget(runtime,target);
      if (targetValidation != ExitCode.SUCCESS) {
        return targetValidation;
      }
      if (runUnder != null && target.getLabel().equals(runUnder.getLabel())) {
        if (runUnderTarget != null) {
          runtime.getReporter().handle(Event.error(null,"String_Node_Str"));
          return ExitCode.COMMAND_LINE_ERROR;
        }
        runUnderTarget=target;
      }
 else       if (targetToRun == null) {
        targetToRun=target;
      }
 else {
        runtime.getReporter().handle(Event.error(SINGLE_TARGET_MESSAGE));
        return ExitCode.COMMAND_LINE_ERROR;
      }
    }
  }
  if ((targetToRun == null) && (runUnderTarget != null)) {
    targetToRun=runUnderTarget;
  }
  if (targetToRun == null) {
    runtime.getReporter().handle(Event.error(NO_TARGET_MESSAGE));
    return ExitCode.COMMAND_LINE_ERROR;
  }
  Path executablePath=Preconditions.checkNotNull(targetToRun.getProvider(FilesToRunProvider.class).getExecutable().getPath());
  BuildConfiguration configuration=targetToRun.getConfiguration();
  if (configuration == null) {
    configuration=runtime.getBuildTool().getView().getConfigurationCollection().getTargetConfigurations().get(0);
  }
  Path workingDir;
  try {
    workingDir=ensureRunfilesBuilt(runtime,targetToRun);
  }
 catch (  CommandException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.LOCAL_ENVIRONMENTAL_ERROR;
  }
  List<String> args=runTargetArgs;
  FilesToRunProvider provider=targetToRun.getProvider(FilesToRunProvider.class);
  RunfilesSupport runfilesSupport=provider == null ? null : provider.getRunfilesSupport();
  if (runfilesSupport != null && runfilesSupport.getArgs() != null) {
    List<String> targetArgs=runfilesSupport.getArgs();
    if (!targetArgs.isEmpty()) {
      args=Lists.newArrayListWithCapacity(targetArgs.size() + runTargetArgs.size());
      args.addAll(targetArgs);
      args.addAll(runTargetArgs);
    }
  }
  PathFragment prettyExecutablePath=OutputDirectoryLinksUtils.getPrettyPath(executablePath,runtime.getWorkspaceName(),runtime.getWorkspace(),options.getOptions(BuildRequestOptions.class).symlinkPrefix);
  List<String> cmdLine=new ArrayList<>();
  if (runOptions.scriptPath == null) {
    cmdLine.add(runtime.getDirectories().getExecRoot().getRelative(runtime.getBinTools().getExecPath(PROCESS_WRAPPER)).getPathString());
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
    cmdLine.add("String_Node_Str");
  }
  List<String> prettyCmdLine=new ArrayList<>();
  if (runUnder != null) {
    String runUnderValue=runUnder.getValue();
    if (runUnderTarget != null) {
      runUnderValue=runUnderTarget.getProvider(FilesToRunProvider.class).getExecutable().getPath().getPathString();
      List<String> opts=runUnder.getOptions();
      if (!opts.isEmpty()) {
        runUnderValue+="String_Node_Str" + ShellEscaper.escapeJoinAll(opts);
      }
    }
    cmdLine.add(configuration.getShExecutable().getPathString());
    cmdLine.add("String_Node_Str");
    cmdLine.add(runUnderValue + "String_Node_Str" + executablePath.getPathString()+ "String_Node_Str"+ ShellEscaper.escapeJoinAll(args));
    prettyCmdLine.add(configuration.getShExecutable().getPathString());
    prettyCmdLine.add("String_Node_Str");
    prettyCmdLine.add(runUnderValue + "String_Node_Str" + prettyExecutablePath.getPathString()+ "String_Node_Str"+ ShellEscaper.escapeJoinAll(args));
  }
 else {
    cmdLine.add(executablePath.getPathString());
    cmdLine.addAll(args);
    prettyCmdLine.add(prettyExecutablePath.getPathString());
    prettyCmdLine.addAll(args);
  }
  outErr.printErrLn("String_Node_Str");
  if (runOptions.scriptPath != null) {
    String unisolatedCommand=CommandFailureUtils.describeCommand(CommandDescriptionForm.COMPLETE_UNISOLATED,cmdLine,null,workingDir.getPathString());
    if (writeScript(runtime,runOptions.scriptPath,unisolatedCommand)) {
      return ExitCode.SUCCESS;
    }
 else {
      return ExitCode.RUN_FAILURE;
    }
  }
  runtime.getReporter().handle(Event.info(null,"String_Node_Str" + ShellEscaper.escapeJoinAll(prettyCmdLine)));
  com.google.devtools.build.lib.shell.Command command=new CommandBuilder().addArgs(cmdLine).setEnv(runtime.getClientEnv()).setWorkingDir(workingDir).build();
  try {
    runtime.getReporter().switchToAnsiAllowingHandler();
    command.execute(com.google.devtools.build.lib.shell.Command.NO_INPUT,com.google.devtools.build.lib.shell.Command.NO_OBSERVER,outErr.getOutputStream(),outErr.getErrorStream(),true).getTerminationStatus().getExitCode();
    return ExitCode.SUCCESS;
  }
 catch (  BadExitStatusException e) {
    String message="String_Node_Str" + e.getResult().getTerminationStatus().getExitCode() + "String_Node_Str"+ e.getMessage();
    runtime.getReporter().handle(Event.error(message));
    return ExitCode.RUN_FAILURE;
  }
catch (  AbnormalTerminationException e) {
    return ExitCode.INTERRUPTED;
  }
catch (  CommandException e) {
    runtime.getReporter().handle(Event.error("String_Node_Str" + e.getMessage()));
    return ExitCode.RUN_FAILURE;
  }
}