Program: 131354
Project: 131354
Buggy source:
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(s,fg.getEdge(i),s.one());
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  if (prm.cacheFactorBeliefs) {
    for (    FgNode node : fg.getNodes()) {
      if (node.isFactor() && !(node.getFactor() instanceof GlobalFactor)) {
        Factor f=node.getFactor();
        VarTensor fBel=new VarTensor(s,f.getVars());
        int c=f.getVars().calcNumConfigs();
        for (int i=0; i < c; i++)         fBel.setValue(i,s.fromLogProb(f.getLogUnormalizedScore(i)));
        for (        FgEdge v2f : node.getInEdges()) {
          VarTensor vBel=msgs[v2f.getId()].message;
          fBel.prod(vBel);
        }
        factorBeliefCache[f.getId()]=fBel;
      }
    }
  }
  List<FgEdge> order=null;
  for (int iter=0; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    order=updateOrder(order,iter);
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
        if (isConverged()) {
          break;
        }
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : order) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
    if (isConverged()) {
      log.trace("String_Node_Str" + (iter + 1));
      break;
    }
  }
  for (  Messages msg : msgs) {
    msg.newMessage=null;
  }
  timer.stop();
}

Fixed version (ground truth):
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(s,fg.getEdge(i),s.one());
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  if (prm.cacheFactorBeliefs) {
    for (    FgNode node : fg.getNodes()) {
      if (node.isFactor() && !(node.getFactor() instanceof GlobalFactor)) {
        Factor f=node.getFactor();
        VarTensor fBel=new VarTensor(s,f.getVars());
        int c=f.getVars().calcNumConfigs();
        for (int i=0; i < c; i++)         fBel.setValue(i,s.fromLogProb(f.getLogUnormalizedScore(i)));
        for (        FgEdge v2f : node.getInEdges()) {
          VarTensor vBel=msgs[v2f.getId()].message;
          fBel.prod(vBel);
        }
        factorBeliefCache[f.getId()]=fBel;
      }
    }
  }
  List<FgEdge> order=null;
  for (int iter=-1; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    order=updateOrder(order,iter);
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
        if (isConverged()) {
          break;
        }
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : order) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
    if (isConverged()) {
      log.trace("String_Node_Str" + (iter + 1));
      break;
    }
  }
  for (  Messages msg : msgs) {
    msg.newMessage=null;
  }
  timer.stop();
}