Program: 6755
Project: 6755
Buggy source:
public void startAllDownloads() throws RobonoboException {
  rbnb.getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      int numStarted=0;
      List<String> dlSidList=db.getDownloadSids();
      for (      String sid : dlSidList) {
        DownloadingTrack d=db.getDownload(sid);
        if (d.getDownloadStatus() == DownloadStatus.Finished) {
          db.deleteDownload(sid);
          continue;
        }
        PageBuffer pb=storage.getPageBuf(sid);
        if (pb == null) {
          log.error("String_Node_Str" + sid + "String_Node_Str");
          db.deleteDownload(sid);
          continue;
        }
        d.setPageBuf(pb);
        if (pb.isComplete()) {
          share.addShareFromCompletedDownload(d);
          db.deleteDownload(sid);
          continue;
        }
synchronized (dPriority) {
          dPriority.add(d.getStream().getStreamId());
        }
synchronized (this) {
          downloadSids.add(sid);
        }
        if (numStarted < rbnb.getConfig().getMaxRunningDownloads()) {
          startDownload(d,pb);
          numStarted++;
        }
 else {
          d.setDownloadStatus(DownloadStatus.Paused);
          db.putDownload(d);
          log.debug("String_Node_Str" + sid);
        }
        rbnb.getEventService().fireTrackUpdated(sid);
      }
      updatePriorities();
      if (rbnb.getConfig().getDownloadCheckFreq() > 0) {
        int freqMs=rbnb.getConfig().getDownloadCheckFreq();
        checkDownloadsTask=rbnb.getExecutor().scheduleAtFixedRate(new CatchingRunnable(){
          public void doRun() throws Exception {
            startMoreDownloads();
          }
        }
,freqMs,freqMs,TimeUnit.SECONDS);
      }
    }
  }
);
}

Fixed version (ground truth):
public void startAllDownloads() throws RobonoboException {
  rbnb.getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      int numStarted=0;
      List<String> dlSidList=db.getDownloadSids();
      for (      String sid : dlSidList) {
        DownloadingTrack d=db.getDownload(sid);
        if (d.getDownloadStatus() == DownloadStatus.Finished) {
          db.deleteDownload(sid);
          continue;
        }
        PageBuffer pb=storage.getPageBuf(sid);
        if (pb == null) {
          log.error("String_Node_Str" + sid + "String_Node_Str");
          db.deleteDownload(sid);
          continue;
        }
        d.setPageBuf(pb);
        if (pb.isComplete()) {
          d.setDownloadStatus(DownloadStatus.Finished);
          share.addShareFromCompletedDownload(d);
          db.deleteDownload(sid);
          continue;
        }
synchronized (dPriority) {
          dPriority.add(d.getStream().getStreamId());
        }
synchronized (this) {
          downloadSids.add(sid);
        }
        if (numStarted < rbnb.getConfig().getMaxRunningDownloads()) {
          startDownload(d,pb);
          numStarted++;
        }
 else {
          d.setDownloadStatus(DownloadStatus.Paused);
          db.putDownload(d);
          log.debug("String_Node_Str" + sid);
        }
        rbnb.getEventService().fireTrackUpdated(sid);
      }
      updatePriorities();
      if (rbnb.getConfig().getDownloadCheckFreq() > 0) {
        int freqMs=rbnb.getConfig().getDownloadCheckFreq();
        checkDownloadsTask=rbnb.getExecutor().scheduleAtFixedRate(new CatchingRunnable(){
          public void doRun() throws Exception {
            startMoreDownloads();
          }
        }
,freqMs,freqMs,TimeUnit.SECONDS);
      }
    }
  }
);
}