Program: 178158
Project: 178158
Buggy source:
/** 
 * On Item Pickup handler
 */
@Override public void run(){
  InvTweaksConfig config=cfgManager.getConfig();
  try {
    InvTweaksContainerSectionManager containerMgr=new InvTweaksContainerSectionManager(mc,InvTweaksContainerSection.INVENTORY);
    int pickupSlot=-1;
    long tStart=System.currentTimeMillis();
    while (pickupSlot == -1 && System.currentTimeMillis() - tStart < InvTweaksConst.SORTING_TIMEOUT) {
      for (int i=0; i < 9; i++) {
        yq stackToCompare=containerMgr.getItemStack(27 + i);
        if (stackToCompare != null) {
          if (hotbarClone[i] == null) {
            pickupSlot=27 + i;
            break;
          }
 else           if (!areItemStacksEqual(stackToCompare,hotbarClone[i])) {
            return;
          }
        }
      }
      Thread.yield();
    }
    List<Integer> prefferedPositions=new LinkedList<Integer>();
    InvTweaksItemTree tree=config.getTree();
    yq stack=containerMgr.getItemStack(pickupSlot);
    List<InvTweaksItemTreeItem> items=tree.getItems(getItemID(stack),getItemDamage(stack));
    for (    InvTweaksConfigSortingRule rule : config.getRules()) {
      if (tree.matches(items,rule.getKeyword())) {
        for (        int slot : rule.getPreferredSlots()) {
          prefferedPositions.add(slot);
        }
      }
    }
    boolean hasToBeMoved=true;
    if (prefferedPositions != null) {
      for (      int newSlot : prefferedPositions) {
        try {
          if (newSlot == pickupSlot) {
            hasToBeMoved=false;
            break;
          }
 else           if (containerMgr.getItemStack(newSlot) == null) {
            if (containerMgr.move(pickupSlot,newSlot)) {
              break;
            }
          }
        }
 catch (        TimeoutException e) {
          logInGameError("String_Node_Str",e);
        }
      }
    }
    if (hasToBeMoved) {
      for (int i=0; i < containerMgr.getSize(); i++) {
        if (containerMgr.getItemStack(i) == null) {
          if (containerMgr.move(pickupSlot,i)) {
            break;
          }
        }
      }
    }
  }
 catch (  Exception e) {
    logInGameError("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * On Item Pickup handler
 */
@Override public void run(){
  InvTweaksConfig config=cfgManager.getConfig();
  try {
    InvTweaksContainerSectionManager containerMgr=new InvTweaksContainerSectionManager(mc,InvTweaksContainerSection.INVENTORY);
    int pickupSlot=-1;
    long tStart=System.currentTimeMillis();
    while (pickupSlot == -1 && System.currentTimeMillis() - tStart < InvTweaksConst.SORTING_TIMEOUT) {
      for (int i=0; i < 9; i++) {
        yq stackToCompare=containerMgr.getItemStack(27 + i);
        if (stackToCompare != null) {
          if (hotbarClone[i] == null) {
            pickupSlot=27 + i;
            break;
          }
 else           if (!areItemStacksEqual(stackToCompare,hotbarClone[i])) {
            return;
          }
        }
      }
      Thread.yield();
    }
    if (pickupSlot != -1) {
      List<Integer> prefferedPositions=new LinkedList<Integer>();
      InvTweaksItemTree tree=config.getTree();
      yq stack=containerMgr.getItemStack(pickupSlot);
      List<InvTweaksItemTreeItem> items=tree.getItems(getItemID(stack),getItemDamage(stack));
      for (      InvTweaksConfigSortingRule rule : config.getRules()) {
        if (tree.matches(items,rule.getKeyword())) {
          for (          int slot : rule.getPreferredSlots()) {
            prefferedPositions.add(slot);
          }
        }
      }
      boolean hasToBeMoved=true;
      if (prefferedPositions != null) {
        for (        int newSlot : prefferedPositions) {
          try {
            if (newSlot == pickupSlot) {
              hasToBeMoved=false;
              break;
            }
 else             if (containerMgr.getItemStack(newSlot) == null) {
              if (containerMgr.move(pickupSlot,newSlot)) {
                break;
              }
            }
          }
 catch (          TimeoutException e) {
            logInGameError("String_Node_Str",e);
          }
        }
      }
      if (hasToBeMoved) {
        for (int i=0; i < containerMgr.getSize(); i++) {
          if (containerMgr.getItemStack(i) == null) {
            if (containerMgr.move(pickupSlot,i)) {
              break;
            }
          }
        }
      }
    }
  }
 catch (  Exception e) {
    logInGameError("String_Node_Str",e);
  }
}