Program: 91863
Project: 91863
Buggy source:
@Override public void launch(ILaunchConfiguration config,String mode,ILaunch launch,IProgressMonitor monitor) throws CoreException {
  this.config=config;
  Oprofile.OprofileProject.setProject(getProject());
  LaunchOptions options=new LaunchOptions();
  options.loadConfiguration(config);
  IPath exePath=getExePath(config);
  options.setBinaryImage(exePath.toOSString());
  Oprofile.OprofileProject.setProfilingBinary(options.getOprofileComboText());
  OprofileDaemonEvent[] daemonEvents=null;
  ArrayList<OprofileDaemonEvent> events=new ArrayList<>();
  if (!config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT,false)) {
    OprofileCounter[] counters=oprofileCounters(config);
    for (int i=0; i < counters.length; ++i) {
      if (counters[i].getEnabled()) {
        OprofileDaemonEvent[] counterEvents=counters[i].getDaemonEvents();
        events.addAll(Arrays.asList(counterEvents));
      }
    }
    daemonEvents=new OprofileDaemonEvent[events.size()];
    events.toArray(daemonEvents);
  }
  if (!preExec(options,daemonEvents,launch)) {
    return;
  }
  Process process=null;
  if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPCONTROL_BINARY)) {
    String arguments[]=getProgramArgumentsArray(config);
    IRemoteCommandLauncher launcher=RemoteProxyManager.getInstance().getLauncher(oprofileProject());
    IPath workingDirPath=new Path(oprofileWorkingDirURI(config).getPath());
    for (int i=0; i < options.getExecutionsNumber(); i++) {
      process=launcher.execute(exePath,arguments,getEnvironment(config),workingDirPath,monitor);
      DebugPlugin.newProcess(launch,process,renderProcessLabel(exePath.toOSString()));
      try {
        process.waitFor();
      }
 catch (      InterruptedException e) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
    }
  }
  if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPERF_BINARY)) {
    String eventsString=null;
    StringBuilder spec=new StringBuilder();
    spec.append(EVENTS);
    boolean isCommaAllowed=false;
    for (int i=0; i < events.size(); i++) {
      OprofileDaemonEvent event=events.get(i);
      if (isCommaAllowed) {
        spec.append(',');
      }
      spec.append(event.getEvent().getText());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append(event.getResetCount());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append(event.getEvent().getUnitMask().getMaskValue());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append((event.getProfileKernel() ? OPD_SETUP_EVENT_TRUE : OPD_SETUP_EVENT_FALSE));
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append((event.getProfileUser() ? OPD_SETUP_EVENT_TRUE : OPD_SETUP_EVENT_FALSE));
      isCommaAllowed=true;
    }
    eventsString=spec.toString();
    ArrayList<String> argArray=new ArrayList<>(Arrays.asList(getProgramArgumentsArray(config)));
    IFolder dataFolder=Oprofile.OprofileProject.getProject().getFolder(OPROFILE_DATA);
    if (!dataFolder.exists()) {
      dataFolder.create(false,true,null);
    }
    argArray.add(0,exePath.toOSString());
    if (events.size() > 0) {
      argArray.add(0,eventsString);
    }
    argArray.add(0,SESSION_DIR + oprofileWorkingDirURI(config).getPath() + IPath.SEPARATOR+ OPROFILE_DATA);
    argArray.add(0,OprofileProject.OPERF_BINARY);
    for (int i=0; i < options.getExecutionsNumber(); i++) {
      if (i != 0) {
        argArray.add(APPEND);
      }
      String[] arguments=new String[argArray.size()];
      arguments=argArray.toArray(arguments);
      try {
        process=RuntimeProcessFactory.getFactory().exec(arguments,OprofileProject.getProject());
      }
 catch (      IOException e1) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
      DebugPlugin.newProcess(launch,process,renderProcessLabel(exePath.toOSString()));
      try {
        process.waitFor();
      }
 catch (      InterruptedException e) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
    }
  }
  postExec(options,daemonEvents,process);
}

Fixed version (ground truth):
@Override public void launch(ILaunchConfiguration config,String mode,ILaunch launch,IProgressMonitor monitor) throws CoreException {
  this.config=config;
  Oprofile.OprofileProject.setProject(getProject());
  LaunchOptions options=new LaunchOptions();
  options.loadConfiguration(config);
  IPath exePath=getExePath(config);
  options.setBinaryImage(exePath.toOSString());
  Oprofile.OprofileProject.setProfilingBinary(options.getOprofileComboText());
  OprofileDaemonEvent[] daemonEvents=null;
  ArrayList<OprofileDaemonEvent> events=new ArrayList<>();
  if (!config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT,false)) {
    OprofileCounter[] counters=oprofileCounters(config);
    for (int i=0; i < counters.length; ++i) {
      if (counters[i].getEnabled()) {
        OprofileDaemonEvent[] counterEvents=counters[i].getDaemonEvents();
        events.addAll(Arrays.asList(counterEvents));
      }
    }
    daemonEvents=new OprofileDaemonEvent[events.size()];
    events.toArray(daemonEvents);
  }
  if (!preExec(options,daemonEvents,launch)) {
    return;
  }
  Process process=null;
  if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPCONTROL_BINARY)) {
    String arguments[]=getProgramArgumentsArray(config);
    IRemoteCommandLauncher launcher=RemoteProxyManager.getInstance().getLauncher(oprofileProject());
    IPath workingDirPath=new Path(oprofileWorkingDirURI(config).getPath());
    for (int i=0; i < options.getExecutionsNumber(); i++) {
      process=launcher.execute(exePath,arguments,getEnvironment(config),workingDirPath,monitor);
      DebugPlugin.newProcess(launch,process,renderProcessLabel(exePath.toOSString()));
      try {
        process.waitFor();
      }
 catch (      InterruptedException e) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
    }
  }
  if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPERF_BINARY)) {
    String eventsString=null;
    StringBuilder spec=new StringBuilder();
    spec.append(EVENTS);
    boolean isCommaAllowed=false;
    for (int i=0; i < events.size(); i++) {
      OprofileDaemonEvent event=events.get(i);
      if (isCommaAllowed) {
        spec.append(',');
      }
      spec.append(event.getEvent().getText());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append(event.getResetCount());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append(event.getEvent().getUnitMask().getMaskValue());
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append((event.getProfileKernel() ? OPD_SETUP_EVENT_TRUE : OPD_SETUP_EVENT_FALSE));
      spec.append(OPD_SETUP_EVENT_SEPARATOR);
      spec.append((event.getProfileUser() ? OPD_SETUP_EVENT_TRUE : OPD_SETUP_EVENT_FALSE));
      isCommaAllowed=true;
    }
    eventsString=spec.toString();
    ArrayList<String> argArray=new ArrayList<>(Arrays.asList(getProgramArgumentsArray(config)));
    IRemoteFileProxy proxy=RemoteProxyManager.getInstance().getFileProxy(OprofileProject.getProject());
    IFileStore dataFolder=proxy.getResource(oprofileWorkingDirURI(config).getPath() + IPath.SEPARATOR + OPROFILE_DATA);
    if (!dataFolder.fetchInfo().exists()) {
      dataFolder.mkdir(EFS.SHALLOW,null);
    }
    argArray.add(0,exePath.toOSString());
    if (events.size() > 0) {
      argArray.add(0,eventsString);
    }
    argArray.add(0,SESSION_DIR + oprofileWorkingDirURI(config).getPath() + IPath.SEPARATOR+ OPROFILE_DATA);
    argArray.add(0,OprofileProject.OPERF_BINARY);
    for (int i=0; i < options.getExecutionsNumber(); i++) {
      if (i != 0) {
        argArray.add(APPEND);
      }
      String[] arguments=new String[argArray.size()];
      arguments=argArray.toArray(arguments);
      try {
        process=RuntimeProcessFactory.getFactory().exec(arguments,OprofileProject.getProject());
      }
 catch (      IOException e1) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
      DebugPlugin.newProcess(launch,process,renderProcessLabel(exePath.toOSString()));
      try {
        process.waitFor();
      }
 catch (      InterruptedException e) {
        process.destroy();
        Status status=new Status(IStatus.ERROR,OprofileLaunchPlugin.PLUGIN_ID,OprofileLaunchMessages.getString("String_Node_Str"));
        throw new CoreException(status);
      }
    }
  }
  postExec(options,daemonEvents,process);
}