Program: 94566
Project: 94566
Buggy source:
public Error.Type render(){
  gui.status("String_Node_Str");
  RenderProcess process=getProcessRender();
  Timer timerOfMaxRenderTime=null;
  String core_script="String_Node_Str";
  String ignore_signal_script="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  if (getUseGPU() && config.getGPUDevice() != null && config.getComputeMethod() != ComputeType.CPU) {
    core_script="String_Node_Str" + config.getGPUDevice().getCudaName() + "String_Node_Str";
    gui.setComputeMethod("String_Node_Str");
  }
 else {
    core_script="String_Node_Str";
    gui.setComputeMethod("String_Node_Str");
  }
  core_script+=ignore_signal_script;
  core_script+=String.format("String_Node_Str",getTileSize());
  File script_file=null;
  String command1[]=getRenderCommand().split("String_Node_Str");
  int size_command=command1.length + 2;
  if (config.getNbCores() > 0) {
    size_command+=2;
  }
  List<String> command=new ArrayList<String>(size_command);
  Map<String,String> new_env=new HashMap<String,String>();
  new_env.put("String_Node_Str",config.workingDirectory.getAbsolutePath().replace("String_Node_Str","String_Node_Str"));
  new_env.put("String_Node_Str",Integer.toString(config.getNbCores()));
  new_env.put("String_Node_Str",Integer.toString(config.getPriority()));
  for (  String arg : command1) {
switch (arg) {
case "String_Node_Str":
      command.add(getScenePath());
    command.add("String_Node_Str");
  try {
    script_file=File.createTempFile("String_Node_Str","String_Node_Str",config.workingDirectory);
    File file=new File(script_file.getAbsolutePath());
    FileWriter txt;
    txt=new FileWriter(file);
    PrintWriter out=new PrintWriter(txt);
    out.write(getScript());
    out.write("String_Node_Str");
    out.write(core_script);
    out.write("String_Node_Str");
    out.close();
    command.add(script_file.getAbsolutePath());
  }
 catch (  IOException e) {
    StringWriter sw=new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    log.error("String_Node_Str" + e + "String_Node_Str"+ sw.toString());
    return Error.Type.UNKNOWN;
  }
script_file.deleteOnExit();
break;
case "String_Node_Str":
command.add(getRendererPath());
if (config.getNbCores() > 0) {
command.add("String_Node_Str");
command.add(Integer.toString(config.getNbCores()));
}
break;
case "String_Node_Str":
command.add(config.workingDirectory.getAbsolutePath() + File.separator + getPrefixOutputImage());
break;
case "String_Node_Str":
command.add(getFrameNumber());
break;
default :
command.add(arg);
break;
}
}
try {
String line;
log.debug(command.toString());
OS os=OS.getOS();
process.setCoresUsed(config.getNbCores());
process.start();
getProcessRender().setProcess(os.exec(command,new_env));
BufferedReader input=new BufferedReader(new InputStreamReader(getProcessRender().getProcess().getInputStream()));
if (config.getMaxRenderTime() > 0) {
timerOfMaxRenderTime=new Timer();
timerOfMaxRenderTime.schedule(new TimerTask(){
@Override public void run(){
RenderProcess process=getProcessRender();
if (process != null) {
long duration=(new Date().getTime() - process.getStartTime()) / 1000;
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
log.debug("String_Node_Str");
OS.getOS().kill(process.getProcess());
setAskForRendererKill(true);
}
}
}
}
,config.getMaxRenderTime() * 1000 + 2000);
}
long last_update_status=0;
log.debug("String_Node_Str");
try {
while ((line=input.readLine()) != null) {
log.debug(line);
updateRenderingMemoryPeak(line);
if (config.getMaxMemory() != -1 && process.getMemoryUsed() > config.getMaxMemory()) {
log.debug("String_Node_Str" + process.getMemoryUsed() + "String_Node_Str"+ config.getMaxMemory()+ "String_Node_Str");
process.finish();
if (script_file != null) {
script_file.delete();
}
return Error.Type.RENDERER_OUT_OF_MEMORY;
}
if ((new Date().getTime() - last_update_status) > 2000) {
updateRenderingStatus(line);
last_update_status=new Date().getTime();
}
Type error=detectError(line);
if (error != Error.Type.OK) {
if (script_file != null) {
script_file.delete();
}
return error;
}
}
input.close();
}
 catch (IOException err1) {
log.error("String_Node_Str" + err1);
}
log.debug("String_Node_Str");
}
 catch (Exception err) {
if (script_file != null) {
script_file.delete();
}
StringWriter sw=new StringWriter();
err.printStackTrace(new PrintWriter(sw));
log.error("String_Node_Str" + err + "String_Node_Str"+ sw.toString());
return Error.Type.FAILED_TO_EXECUTE;
}
int exit_value=process.exitValue();
process.finish();
if (timerOfMaxRenderTime != null) {
timerOfMaxRenderTime.cancel();
}
if (script_file != null) {
script_file.delete();
}
final String filename_without_extension=getPrefixOutputImage() + getFrameNumber();
FilenameFilter textFilter=new FilenameFilter(){
public boolean accept(File dir,String name){
return name.startsWith(filename_without_extension);
}
}
;
File[] files=config.workingDirectory.listFiles(textFilter);
if (getAskForRendererKill()) {
log.debug("String_Node_Str");
long duration=(new Date().getTime() - process.getStartTime()) / 1000;
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
log.debug("String_Node_Str" + duration + "String_Node_Str"+ config.getMaxRenderTime()+ "String_Node_Str");
return Error.Type.RENDERER_KILLED_BY_USER_OVER_TIME;
}
if (files.length != 0) {
new File(files[0].getAbsolutePath()).delete();
}
if (getServerBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_SERVER;
}
if (getUserBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_USER;
}
return Error.Type.RENDERER_KILLED;
}
if (files.length == 0) {
log.error("String_Node_Str" + filename_without_extension + "String_Node_Str");
String basename="String_Node_Str";
try {
basename=getPath().substring(0,getPath().lastIndexOf('.'));
}
 catch (Exception e) {
e.printStackTrace();
}
File crash_file=new File(config.workingDirectory + File.separator + basename+ "String_Node_Str");
if (crash_file.exists()) {
log.error("String_Node_Str");
crash_file.delete();
return Error.Type.RENDERER_CRASHED;
}
if (exit_value == 127 && process.getDuration() < 10) {
log.error("String_Node_Str" + process.getDuration() + "String_Node_Str");
return Error.Type.RENDERER_MISSING_LIBRARIES;
}
return Error.Type.NOOUTPUTFILE;
}
 else {
setOutputImagePath(files[0].getAbsolutePath());
log.debug("String_Node_Str" + getOutputImagePath() + "String_Node_Str");
}
File scene_dir=new File(getSceneDirectory());
long date_modification_scene_directory=(long)Utils.lastModificationTime(scene_dir);
if (date_modification_scene_directory > process.getStartTime()) {
scene_dir.delete();
}
gui.status(String.format("String_Node_Str",process.getDuration() / 60,process.getDuration() % 60));
return Error.Type.OK;
}

Fixed version (ground truth):
public Error.Type render(){
  gui.status("String_Node_Str");
  RenderProcess process=getProcessRender();
  Timer timerOfMaxRenderTime=null;
  String core_script="String_Node_Str";
  String ignore_signal_script="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  if (getUseGPU() && config.getGPUDevice() != null && config.getComputeMethod() != ComputeType.CPU) {
    core_script="String_Node_Str" + config.getGPUDevice().getCudaName() + "String_Node_Str";
    gui.setComputeMethod("String_Node_Str");
  }
 else {
    core_script="String_Node_Str";
    gui.setComputeMethod("String_Node_Str");
  }
  core_script+=ignore_signal_script;
  core_script+=String.format("String_Node_Str",getTileSize());
  File script_file=null;
  String command1[]=getRenderCommand().split("String_Node_Str");
  int size_command=command1.length + 2;
  if (config.getNbCores() > 0) {
    size_command+=2;
  }
  List<String> command=new ArrayList<String>(size_command);
  Map<String,String> new_env=new HashMap<String,String>();
  new_env.put("String_Node_Str",config.workingDirectory.getAbsolutePath().replace("String_Node_Str","String_Node_Str"));
  new_env.put("String_Node_Str",Integer.toString(config.getNbCores()));
  new_env.put("String_Node_Str",Integer.toString(config.getPriority()));
  for (  String arg : command1) {
switch (arg) {
case "String_Node_Str":
      command.add(getScenePath());
    command.add("String_Node_Str");
  try {
    script_file=File.createTempFile("String_Node_Str","String_Node_Str",config.workingDirectory);
    File file=new File(script_file.getAbsolutePath());
    FileWriter txt;
    txt=new FileWriter(file);
    PrintWriter out=new PrintWriter(txt);
    out.write(getScript());
    out.write("String_Node_Str");
    out.write(core_script);
    out.write("String_Node_Str");
    out.close();
    command.add(script_file.getAbsolutePath());
  }
 catch (  IOException e) {
    StringWriter sw=new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    log.error("String_Node_Str" + e + "String_Node_Str"+ sw.toString());
    return Error.Type.UNKNOWN;
  }
script_file.deleteOnExit();
break;
case "String_Node_Str":
command.add(getRendererPath());
if (config.getNbCores() > 0) {
command.add("String_Node_Str");
command.add(Integer.toString(config.getNbCores()));
}
break;
case "String_Node_Str":
command.add(config.workingDirectory.getAbsolutePath() + File.separator + getPrefixOutputImage());
break;
case "String_Node_Str":
command.add(getFrameNumber());
break;
default :
command.add(arg);
break;
}
}
try {
String line;
log.debug(command.toString());
OS os=OS.getOS();
process.setCoresUsed(config.getNbCores());
process.start();
getProcessRender().setProcess(os.exec(command,new_env));
BufferedReader input=new BufferedReader(new InputStreamReader(getProcessRender().getProcess().getInputStream()));
if (config.getMaxRenderTime() > 0) {
timerOfMaxRenderTime=new Timer();
timerOfMaxRenderTime.schedule(new TimerTask(){
@Override public void run(){
RenderProcess process=getProcessRender();
if (process != null) {
long duration=(new Date().getTime() - process.getStartTime()) / 1000;
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
log.debug("String_Node_Str");
OS.getOS().kill(process.getProcess());
setAskForRendererKill(true);
}
}
}
}
,config.getMaxRenderTime() * 1000 + 2000);
}
long last_update_status=0;
log.debug("String_Node_Str");
try {
while ((line=input.readLine()) != null) {
log.debug(line);
updateRenderingMemoryPeak(line);
if (config.getMaxMemory() != -1 && process.getMemoryUsed() > config.getMaxMemory()) {
log.debug("String_Node_Str" + process.getMemoryUsed() + "String_Node_Str"+ config.getMaxMemory()+ "String_Node_Str");
OS.getOS().kill(process.getProcess());
process.finish();
if (script_file != null) {
script_file.delete();
}
return Error.Type.RENDERER_OUT_OF_MEMORY;
}
if ((new Date().getTime() - last_update_status) > 2000) {
updateRenderingStatus(line);
last_update_status=new Date().getTime();
}
Type error=detectError(line);
if (error != Error.Type.OK) {
if (script_file != null) {
script_file.delete();
}
return error;
}
}
input.close();
}
 catch (IOException err1) {
log.error("String_Node_Str" + err1);
}
log.debug("String_Node_Str");
}
 catch (Exception err) {
if (script_file != null) {
script_file.delete();
}
StringWriter sw=new StringWriter();
err.printStackTrace(new PrintWriter(sw));
log.error("String_Node_Str" + err + "String_Node_Str"+ sw.toString());
return Error.Type.FAILED_TO_EXECUTE;
}
int exit_value=process.exitValue();
process.finish();
if (timerOfMaxRenderTime != null) {
timerOfMaxRenderTime.cancel();
}
if (script_file != null) {
script_file.delete();
}
final String filename_without_extension=getPrefixOutputImage() + getFrameNumber();
FilenameFilter textFilter=new FilenameFilter(){
public boolean accept(File dir,String name){
return name.startsWith(filename_without_extension);
}
}
;
File[] files=config.workingDirectory.listFiles(textFilter);
if (getAskForRendererKill()) {
log.debug("String_Node_Str");
long duration=(new Date().getTime() - process.getStartTime()) / 1000;
if (config.getMaxRenderTime() > 0 && duration > config.getMaxRenderTime()) {
log.debug("String_Node_Str" + duration + "String_Node_Str"+ config.getMaxRenderTime()+ "String_Node_Str");
return Error.Type.RENDERER_KILLED_BY_USER_OVER_TIME;
}
if (files.length != 0) {
new File(files[0].getAbsolutePath()).delete();
}
if (getServerBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_SERVER;
}
if (getUserBlockJob()) {
return Error.Type.RENDERER_KILLED_BY_USER;
}
return Error.Type.RENDERER_KILLED;
}
if (files.length == 0) {
log.error("String_Node_Str" + filename_without_extension + "String_Node_Str");
String basename="String_Node_Str";
try {
basename=getPath().substring(0,getPath().lastIndexOf('.'));
}
 catch (Exception e) {
e.printStackTrace();
}
File crash_file=new File(config.workingDirectory + File.separator + basename+ "String_Node_Str");
if (crash_file.exists()) {
log.error("String_Node_Str");
crash_file.delete();
return Error.Type.RENDERER_CRASHED;
}
if (exit_value == 127 && process.getDuration() < 10) {
log.error("String_Node_Str" + process.getDuration() + "String_Node_Str");
return Error.Type.RENDERER_MISSING_LIBRARIES;
}
return Error.Type.NOOUTPUTFILE;
}
 else {
setOutputImagePath(files[0].getAbsolutePath());
log.debug("String_Node_Str" + getOutputImagePath() + "String_Node_Str");
}
File scene_dir=new File(getSceneDirectory());
long date_modification_scene_directory=(long)Utils.lastModificationTime(scene_dir);
if (date_modification_scene_directory > process.getStartTime()) {
scene_dir.delete();
}
gui.status(String.format("String_Node_Str",process.getDuration() / 60,process.getDuration() % 60));
return Error.Type.OK;
}