Program: 12321
Project: 12321
Buggy source:
/** 
 * This decides the given context slot. It normally returns TRUE, but returns FALSE if the ONLY change as a result of the decision procedure was a change in the set of ^item's on the impasse below the given slot. <p>decide.cpp:2092:decide_context_slot
 * @param goal
 * @param s
 * @param predict (defaulted to false in CSoar)
 * @return
 */
private boolean decide_context_slot(IdentifierImpl goal,Slot s,boolean predict){
  ImpasseType impasse_type;
  SymbolImpl attribute_of_impasse;
  final ByRef<Preference> candidates=ByRef.create(null);
  if (!context_slot_is_decidable(s)) {
    impasse_type=ImpasseType.NO_CHANGE_IMPASSE_TYPE;
    candidates.value=null;
    if (predict) {
      context.decisionManip.predict_set("String_Node_Str");
      return true;
    }
  }
 else {
    impasse_type=run_preference_semantics(s,candidates,false,false);
    if (predict) {
switch (impasse_type) {
case CONSTRAINT_FAILURE_IMPASSE_TYPE:
        context.decisionManip.predict_set("String_Node_Str");
      break;
case CONFLICT_IMPASSE_TYPE:
    context.decisionManip.predict_set("String_Node_Str");
  break;
case TIE_IMPASSE_TYPE:
context.decisionManip.predict_set("String_Node_Str");
break;
case NO_CHANGE_IMPASSE_TYPE:
context.decisionManip.predict_set("String_Node_Str");
break;
default :
if (candidates.value == null || (candidates.value.value.asIdentifier() == null)) context.decisionManip.predict_set("String_Node_Str");
 else {
IdentifierImpl tempId=candidates.value.value.asIdentifier();
String temp="String_Node_Str" + tempId.name_letter + tempId.name_number;
context.decisionManip.predict_set(temp);
}
break;
}
return true;
}
remove_wmes_for_context_slot(s);
if (impasse_type == ImpasseType.NONE_IMPASSE_TYPE) {
if (candidates.value == null) {
impasse_type=ImpasseType.NO_CHANGE_IMPASSE_TYPE;
}
 else if (candidates.value.next_candidate != null) {
throw new IllegalStateException("String_Node_Str");
}
}
}
s.changed=null;
if (impasse_type == ImpasseType.NO_CHANGE_IMPASSE_TYPE) {
if (s.getWmes() != null) {
attribute_of_impasse=s.attr;
}
 else {
attribute_of_impasse=context.predefinedSyms.state_symbol;
}
}
 else {
attribute_of_impasse=s.attr;
}
if (attribute_of_impasse == context.predefinedSyms.state_symbol) {
remove_wmes_for_context_slot(goal.operator_slot);
}
if (impasse_type == ImpasseType.NONE_IMPASSE_TYPE) {
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) remove_existing_context_and_descendents(goal.lower_goal);
WmeImpl w=context.workingMemory.make_wme(s.id,s.attr,candidates.value.value,false);
s.addWme(w);
w.preference=candidates.value;
w.preference.preference_add_ref();
context.workingMemory.add_wme_to_wm(w);
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(context.recMemory);
if (context.rl.rl_enabled()) context.rl.rl_store_data(goal,candidates.value);
return true;
}
if (impasse_type != ImpasseType.NO_CHANGE_IMPASSE_TYPE) goal.rl_info.impasse_type=impasse_type;
 else if (s.getWmes() != null) goal.rl_info.impasse_type=ImpasseType.OP_NO_CHANGE_IMPASSE_TYPE;
 else goal.rl_info.impasse_type=ImpasseType.STATE_NO_CHANGE_IMPASSE_TYPE;
if ((impasse_type == type_of_existing_impasse(goal)) && (attribute_of_impasse == attribute_of_existing_impasse(goal))) {
update_impasse_items(goal.lower_goal,candidates.value);
return false;
}
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) remove_existing_context_and_descendents(goal.lower_goal);
if (context.operand2_mode && this.waitsnc && (impasse_type == ImpasseType.NO_CHANGE_IMPASSE_TYPE)&& (attribute_of_impasse == context.predefinedSyms.state_symbol)) {
this.waitsnc_detect=true;
}
 else {
create_new_context(attribute_of_impasse,impasse_type);
update_impasse_items(goal.lower_goal,candidates.value);
}
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(context.recMemory);
return true;
}

Fixed version (ground truth):
/** 
 * This decides the given context slot. It normally returns TRUE, but returns FALSE if the ONLY change as a result of the decision procedure was a change in the set of ^item's on the impasse below the given slot. <p>decide.cpp:2092:decide_context_slot
 * @param goal
 * @param s
 * @param predict (defaulted to false in CSoar)
 * @return
 */
private boolean decide_context_slot(IdentifierImpl goal,Slot s,boolean predict){
  ImpasseType impasse_type;
  SymbolImpl attribute_of_impasse;
  final ByRef<Preference> candidates=ByRef.create(null);
  if (!context_slot_is_decidable(s)) {
    impasse_type=ImpasseType.NO_CHANGE_IMPASSE_TYPE;
    candidates.value=null;
    if (predict) {
      context.decisionManip.predict_set("String_Node_Str");
      return true;
    }
  }
 else {
    impasse_type=run_preference_semantics(s,candidates,false,false);
    if (predict) {
switch (impasse_type) {
case CONSTRAINT_FAILURE_IMPASSE_TYPE:
        context.decisionManip.predict_set("String_Node_Str");
      break;
case CONFLICT_IMPASSE_TYPE:
    context.decisionManip.predict_set("String_Node_Str");
  break;
case TIE_IMPASSE_TYPE:
context.decisionManip.predict_set("String_Node_Str");
break;
case NO_CHANGE_IMPASSE_TYPE:
context.decisionManip.predict_set("String_Node_Str");
break;
default :
if (candidates.value == null || (candidates.value.value.asIdentifier() == null)) context.decisionManip.predict_set("String_Node_Str");
 else {
IdentifierImpl tempId=candidates.value.value.asIdentifier();
String temp=String.format("String_Node_Str",tempId);
context.decisionManip.predict_set(temp);
}
break;
}
return true;
}
remove_wmes_for_context_slot(s);
if (impasse_type == ImpasseType.NONE_IMPASSE_TYPE) {
if (candidates.value == null) {
impasse_type=ImpasseType.NO_CHANGE_IMPASSE_TYPE;
}
 else if (candidates.value.next_candidate != null) {
throw new IllegalStateException("String_Node_Str");
}
}
}
s.changed=null;
if (impasse_type == ImpasseType.NO_CHANGE_IMPASSE_TYPE) {
if (s.getWmes() != null) {
attribute_of_impasse=s.attr;
}
 else {
attribute_of_impasse=context.predefinedSyms.state_symbol;
}
}
 else {
attribute_of_impasse=s.attr;
}
if (attribute_of_impasse == context.predefinedSyms.state_symbol) {
remove_wmes_for_context_slot(goal.operator_slot);
}
if (impasse_type == ImpasseType.NONE_IMPASSE_TYPE) {
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) remove_existing_context_and_descendents(goal.lower_goal);
WmeImpl w=context.workingMemory.make_wme(s.id,s.attr,candidates.value.value,false);
s.addWme(w);
w.preference=candidates.value;
w.preference.preference_add_ref();
context.workingMemory.add_wme_to_wm(w);
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(context.recMemory);
if (context.rl.rl_enabled()) context.rl.rl_store_data(goal,candidates.value);
return true;
}
if (impasse_type != ImpasseType.NO_CHANGE_IMPASSE_TYPE) goal.rl_info.impasse_type=impasse_type;
 else if (s.getWmes() != null) goal.rl_info.impasse_type=ImpasseType.OP_NO_CHANGE_IMPASSE_TYPE;
 else goal.rl_info.impasse_type=ImpasseType.STATE_NO_CHANGE_IMPASSE_TYPE;
if ((impasse_type == type_of_existing_impasse(goal)) && (attribute_of_impasse == attribute_of_existing_impasse(goal))) {
update_impasse_items(goal.lower_goal,candidates.value);
return false;
}
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) remove_existing_context_and_descendents(goal.lower_goal);
if (context.operand2_mode && this.waitsnc && (impasse_type == ImpasseType.NO_CHANGE_IMPASSE_TYPE)&& (attribute_of_impasse == context.predefinedSyms.state_symbol)) {
this.waitsnc_detect=true;
}
 else {
create_new_context(attribute_of_impasse,impasse_type);
update_impasse_items(goal.lower_goal,candidates.value);
}
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(context.recMemory);
return true;
}