Program: 149827
Project: 149827
Buggy source:
private void establishDefragSpillThreshold(ChunkList chunkMap,ImmixSpace space){
  int availableLines;
  if (TMP_VERBOSE_DEFRAG_STATS || !TMP_USE_NAIVE_SPILL_DEFRAG_THRESHOLD) {
    availableLines=space.getAvailableLines(spillAvailHistogram);
    if (TMP_VERBOSE_DEFRAG_STATS) {
      Log.write("String_Node_Str");
      Log.write(availableLines);
      Log.write("String_Node_Str");
      Log.write(availableLines << LOG_BYTES_IN_LINE);
      Log.writeln("String_Node_Str");
      Defrag.defragBytesAvailable.inc(availableLines << LOG_BYTES_IN_LINE);
    }
  }
  if (TMP_USE_NAIVE_SPILL_DEFRAG_THRESHOLD)   defragSpillThreshold=(short)(Options.defragSimpleSpillThreshold.getValue() * MAX_CONSV_SPILL_COUNT);
 else {
    if (!TMP_EAGER_SPILL_MARK_HISTO_CONSTRUCTION)     updateMarkHistogram(chunkMap);
    availableLines+=availableCleanPagesForDefrag << (LOG_BYTES_IN_PAGE - LOG_BYTES_IN_LINE);
    int requiredLines=0;
    short threshold=(short)(TMP_TRIAL_MARK_HISTO ? 0 : MAX_CONSV_SPILL_COUNT);
    int limit=(int)(availableLines / Options.defragLineReuseRatio.getValue());
    int collectors=VM.activePlan.collectorCount();
    for (short index=MAX_CONSV_SPILL_COUNT; index >= TMP_MIN_SPILL_THRESHOLD && limit > requiredLines; index--) {
      threshold=(short)(TMP_TRIAL_MARK_HISTO ? MAX_CONSV_SPILL_COUNT - index : index);
      int thisBucketMark=0;
      int thisBucketAvail=0;
      if (TMP_EAGER_SPILL_MARK_HISTO_CONSTRUCTION)       for (int c=0; c < collectors; c++)       thisBucketMark+=spillMarkHistograms[c][threshold];
 else       thisBucketMark=spillMarkHistogram[threshold];
      if (TMP_DECREASE_AVAIL_WHEN_CALC_THRESHOLD) {
        if (TMP_EAGER_SPILL_AVAIL_HISTO_CONSTRUCTION)         for (int c=0; c < collectors; c++)         thisBucketAvail+=spillAvailHistograms[c][threshold];
 else         thisBucketAvail=spillAvailHistogram[threshold];
      }
      if (TMP_VERBOSE_DEFRAG_STATS && Options.verbose.getValue() >= 1) {
        Log.write("String_Node_Str");
        Log.write(threshold);
        Log.write("String_Node_Str");
        Log.write(thisBucketMark);
        Log.write("String_Node_Str");
        Log.write(thisBucketAvail);
        Log.write("String_Node_Str");
        Log.write(requiredLines);
        Log.write("String_Node_Str");
        Log.write(availableLines);
        Log.write("String_Node_Str");
        Log.write(limit);
        Log.writeln("String_Node_Str");
      }
      if (TMP_DECREASE_AVAIL_WHEN_CALC_THRESHOLD)       limit-=thisBucketAvail;
      requiredLines+=thisBucketMark;
    }
    defragSpillThreshold=threshold;
  }
}

Fixed version (ground truth):
private void establishDefragSpillThreshold(ChunkList chunkMap,ImmixSpace space){
  int availableLines;
  if (TMP_VERBOSE_DEFRAG_STATS || !TMP_USE_NAIVE_SPILL_DEFRAG_THRESHOLD) {
    availableLines=space.getAvailableLines(spillAvailHistogram);
    if (TMP_VERBOSE_DEFRAG_STATS && Options.verbose.getValue() >= 1) {
      Log.write("String_Node_Str");
      Log.write(availableLines);
      Log.write("String_Node_Str");
      Log.write(availableLines << LOG_BYTES_IN_LINE);
      Log.writeln("String_Node_Str");
      Defrag.defragBytesAvailable.inc(availableLines << LOG_BYTES_IN_LINE);
    }
  }
  if (TMP_USE_NAIVE_SPILL_DEFRAG_THRESHOLD)   defragSpillThreshold=(short)(Options.defragSimpleSpillThreshold.getValue() * MAX_CONSV_SPILL_COUNT);
 else {
    if (!TMP_EAGER_SPILL_MARK_HISTO_CONSTRUCTION)     updateMarkHistogram(chunkMap);
    availableLines+=availableCleanPagesForDefrag << (LOG_BYTES_IN_PAGE - LOG_BYTES_IN_LINE);
    int requiredLines=0;
    short threshold=(short)(TMP_TRIAL_MARK_HISTO ? 0 : MAX_CONSV_SPILL_COUNT);
    int limit=(int)(availableLines / Options.defragLineReuseRatio.getValue());
    int collectors=VM.activePlan.collectorCount();
    for (short index=MAX_CONSV_SPILL_COUNT; index >= TMP_MIN_SPILL_THRESHOLD && limit > requiredLines; index--) {
      threshold=(short)(TMP_TRIAL_MARK_HISTO ? MAX_CONSV_SPILL_COUNT - index : index);
      int thisBucketMark=0;
      int thisBucketAvail=0;
      if (TMP_EAGER_SPILL_MARK_HISTO_CONSTRUCTION)       for (int c=0; c < collectors; c++)       thisBucketMark+=spillMarkHistograms[c][threshold];
 else       thisBucketMark=spillMarkHistogram[threshold];
      if (TMP_DECREASE_AVAIL_WHEN_CALC_THRESHOLD) {
        if (TMP_EAGER_SPILL_AVAIL_HISTO_CONSTRUCTION)         for (int c=0; c < collectors; c++)         thisBucketAvail+=spillAvailHistograms[c][threshold];
 else         thisBucketAvail=spillAvailHistogram[threshold];
      }
      if (TMP_VERBOSE_DEFRAG_STATS && Options.verbose.getValue() >= 1) {
        Log.write("String_Node_Str");
        Log.write(threshold);
        Log.write("String_Node_Str");
        Log.write(thisBucketMark);
        Log.write("String_Node_Str");
        Log.write(thisBucketAvail);
        Log.write("String_Node_Str");
        Log.write(requiredLines);
        Log.write("String_Node_Str");
        Log.write(availableLines);
        Log.write("String_Node_Str");
        Log.write(limit);
        Log.writeln("String_Node_Str");
      }
      if (TMP_DECREASE_AVAIL_WHEN_CALC_THRESHOLD)       limit-=thisBucketAvail;
      requiredLines+=thisBucketMark;
    }
    defragSpillThreshold=threshold;
  }
}