Program: 12277
Project: 12277
Buggy source:
public Symbol rl_build_template_instantiation(Instantiation my_template_instance,Token tok,WmeImpl w){
  Production my_template=my_template_instance.prod;
  MakeAction my_action=my_template.action_list.asMakeAction();
  boolean chunk_var=this.chunker.variablize_this_chunk;
  IdentifierImpl id=my_agent.recMemory.instantiate_rhs_value(my_action.id,-1,'s',tok,w).asIdentifier();
  SymbolImpl attr=my_agent.recMemory.instantiate_rhs_value(my_action.attr,id.level,'a',tok,w);
  char first_letter=attr.getFirstLetter();
  SymbolImpl value=my_agent.recMemory.instantiate_rhs_value(my_action.value,id.level,first_letter,tok,w);
  SymbolImpl referent=my_agent.recMemory.instantiate_rhs_value(my_action.referent,id.level,first_letter,tok,w);
  this.chunker.variablize_this_chunk=true;
  this.chunker.variablization_tc=-1;
  MakeAction new_action=rl_make_simple_action(id,attr,value,referent);
  new_action.preference_type=PreferenceType.NUMERIC_INDIFFERENT;
  StringSymbol new_name_symbol;
  String new_name="String_Node_Str";
  String empty_string="String_Node_Str";
  int new_id=0;
  do {
    new_id=rl_next_template_id();
    new_name=("String_Node_Str" + empty_string + my_template.getName().getValue()+ "String_Node_Str"+ new_id);
  }
 while (my_agent.getSymbols().findString(new_name) != null);
  new_name_symbol=my_agent.getSymbols().createString(new_name);
  ByRef<Condition> cond_top=ByRef.create(null);
  ByRef<Condition> cond_bottom=ByRef.create(null);
  Condition.copy_condition_list(my_template_instance.top_of_instantiated_conditions,cond_top,cond_bottom);
  rl_add_goal_or_impasse_tests_to_conds(cond_top.value);
  variableGenerator.reset(cond_top.value,null);
  this.chunker.variablization_tc=my_agent.syms.get_new_tc_number();
  this.chunker.variablize_condition_list(cond_top.value);
  this.chunker.variablize_nots_and_insert_into_conditions(my_template_instance.nots,cond_top.value);
  Production new_production=new Production(ProductionType.USER,new_name_symbol,cond_top.value,cond_bottom.value,new_action);
  try {
    ((DefaultProductionManager)my_agent.getProductions()).addProduction(new_production,false);
  }
 catch (  ReordererException e) {
    e.printStackTrace();
  }
  this.chunker.variablize_this_chunk=chunk_var;
  return new_name_symbol;
}

Fixed version (ground truth):
public Symbol rl_build_template_instantiation(Instantiation my_template_instance,Token tok,WmeImpl w){
  Production my_template=my_template_instance.prod;
  MakeAction my_action=my_template.action_list.asMakeAction();
  boolean chunk_var=this.chunker.variablize_this_chunk;
  this.chunker.variablize_this_chunk=true;
  StringSymbol new_name_symbol;
  String new_name="String_Node_Str";
  String empty_string="String_Node_Str";
  int new_id=0;
  do {
    new_id=rl_next_template_id();
    new_name=("String_Node_Str" + empty_string + my_template.getName().getValue()+ "String_Node_Str"+ new_id);
  }
 while (my_agent.getSymbols().findString(new_name) != null);
  new_name_symbol=my_agent.getSymbols().createString(new_name);
  ByRef<Condition> cond_top=ByRef.create(null);
  ByRef<Condition> cond_bottom=ByRef.create(null);
  Condition.copy_condition_list(my_template_instance.top_of_instantiated_conditions,cond_top,cond_bottom);
  rl_add_goal_or_impasse_tests_to_conds(cond_top.value);
  this.chunker.variableGenerator.reset(cond_top.value,null);
  this.chunker.variablization_tc=my_agent.syms.get_new_tc_number();
  this.chunker.variablize_condition_list(cond_top.value);
  this.chunker.variablize_nots_and_insert_into_conditions(my_template_instance.nots,cond_top.value);
  IdentifierImpl id=my_agent.recMemory.instantiate_rhs_value(my_action.id,-1,'s',tok,w).asIdentifier();
  SymbolImpl attr=my_agent.recMemory.instantiate_rhs_value(my_action.attr,id.level,'a',tok,w);
  char first_letter=attr.getFirstLetter();
  SymbolImpl value=my_agent.recMemory.instantiate_rhs_value(my_action.value,id.level,first_letter,tok,w);
  SymbolImpl referent=my_agent.recMemory.instantiate_rhs_value(my_action.referent,id.level,first_letter,tok,w);
  MakeAction new_action=rl_make_simple_action(id,attr,value,referent);
  new_action.preference_type=PreferenceType.NUMERIC_INDIFFERENT;
  Production new_production=new Production(ProductionType.USER,new_name_symbol,cond_top.value,cond_bottom.value,new_action);
  try {
    ((DefaultProductionManager)my_agent.getProductions()).addProduction(new_production,false);
  }
 catch (  ReordererException e) {
    e.printStackTrace();
  }
  this.chunker.variablize_this_chunk=chunk_var;
  return new_name_symbol;
}