Program: 12272
Project: 12272
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;
    candidates.value=null;
    if (predict) {
      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:
        decisionManip.predict_set("String_Node_Str");
      break;
case CONFLICT:
    decisionManip.predict_set("String_Node_Str");
  break;
case TIE:
decisionManip.predict_set("String_Node_Str");
break;
case NO_CHANGE:
decisionManip.predict_set("String_Node_Str");
break;
default :
if (candidates.value == null || (candidates.value.value.asIdentifier() == null)) decisionManip.predict_set("String_Node_Str");
 else {
final IdentifierImpl tempId=candidates.value.value.asIdentifier();
final String temp=String.format("String_Node_Str",tempId);
decisionManip.predict_set(temp);
}
break;
}
return true;
}
remove_wmes_for_context_slot(s);
if (impasse_type == ImpasseType.NONE) {
if (candidates.value == null) {
impasse_type=ImpasseType.NO_CHANGE;
}
 else if (candidates.value.next_candidate != null) {
throw new IllegalStateException("String_Node_Str");
}
}
}
s.changed=null;
if (impasse_type == ImpasseType.NO_CHANGE) {
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) {
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) {
if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES)) context.getTrace().print("String_Node_Str",goal.lower_goal);
remove_existing_context_and_descendents(goal.lower_goal);
}
WmeImpl w=this.workingMemory.make_wme(s.id,s.attr,candidates.value.value,false);
s.addWme(w);
w.preference=candidates.value;
w.preference.preference_add_ref();
this.workingMemory.add_wme_to_wm(w);
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(recMemory);
if (rl.rl_enabled()) rl.rl_store_data(goal,candidates.value);
return true;
}
if (impasse_type != ImpasseType.NO_CHANGE) goal.rl_info.impasse_type=impasse_type;
 else if (s.getWmes() != null) goal.rl_info.impasse_type=ImpasseType.OP_NO_CHANGE;
 else goal.rl_info.impasse_type=ImpasseType.STATE_NO_CHANGE;
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) {
if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES)) context.getTrace().print("String_Node_Str",goal.lower_goal);
remove_existing_context_and_descendents(goal.lower_goal);
}
if (this.waitsnc.value.get() && (impasse_type == ImpasseType.NO_CHANGE) && (attribute_of_impasse == context.predefinedSyms.state_symbol)) {
}
 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(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;
    candidates.value=null;
    if (predict) {
      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:
        decisionManip.predict_set("String_Node_Str");
      break;
case CONFLICT:
    decisionManip.predict_set("String_Node_Str");
  break;
case TIE:
decisionManip.predict_set("String_Node_Str");
break;
case NO_CHANGE:
decisionManip.predict_set("String_Node_Str");
break;
default :
if (candidates.value == null || (candidates.value.value.asIdentifier() == null)) decisionManip.predict_set("String_Node_Str");
 else {
final IdentifierImpl tempId=candidates.value.value.asIdentifier();
final String temp=String.format("String_Node_Str",tempId);
decisionManip.predict_set(temp);
}
break;
}
return true;
}
remove_wmes_for_context_slot(s);
if (impasse_type == ImpasseType.NONE) {
if (candidates.value == null) {
impasse_type=ImpasseType.NO_CHANGE;
}
 else if (candidates.value.next_candidate != null) {
throw new IllegalStateException("String_Node_Str");
}
}
}
s.changed=null;
if (impasse_type == ImpasseType.NO_CHANGE) {
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) {
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_add_ref();
if (goal.lower_goal != null) {
context.getTrace().print(EnumSet.of(Category.VERBOSE,Category.WM_CHANGES),"String_Node_Str",goal.lower_goal);
remove_existing_context_and_descendents(goal.lower_goal);
}
WmeImpl w=this.workingMemory.make_wme(s.id,s.attr,candidates.value.value,false);
s.addWme(w);
w.preference=candidates.value;
w.preference.preference_add_ref();
this.workingMemory.add_wme_to_wm(w);
for (Preference temp=candidates.value; temp != null; temp=temp.next_candidate) temp.preference_remove_ref(recMemory);
if (rl.rl_enabled()) rl.rl_store_data(goal,candidates.value);
return true;
}
if (impasse_type != ImpasseType.NO_CHANGE) goal.rl_info.impasse_type=impasse_type;
 else if (s.getWmes() != null) goal.rl_info.impasse_type=ImpasseType.OP_NO_CHANGE;
 else goal.rl_info.impasse_type=ImpasseType.STATE_NO_CHANGE;
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) {
context.getTrace().print(EnumSet.of(Category.VERBOSE,Category.WM_CHANGES),"String_Node_Str",goal.lower_goal);
remove_existing_context_and_descendents(goal.lower_goal);
}
if (this.waitsnc.value.get() && (impasse_type == ImpasseType.NO_CHANGE) && (attribute_of_impasse == context.predefinedSyms.state_symbol)) {
}
 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(recMemory);
return true;
}