Program: 56104
Project: 56104
Buggy source:
/** 
 * Entry point of the thread.
 */
public void go() throws IOException {
  final Channel.Enumerator enumerator=this.ioManager.createChannelEnumerator();
  final List<MemorySegment> writeBuffers;
  List<Channel.ID> channelIDs=new ArrayList<Channel.ID>();
  try {
    writeBuffers=this.memoryManager.allocate(CombiningUnilateralSortMerger.this.parent,writeMemSize,NUM_WRITE_BUFFERS,MIN_IO_BUFFER_SIZE);
    registerSegmentsToBeFreedAtShutdown(writeBuffers);
  }
 catch (  MemoryAllocationException maex) {
    throw new IOException("String_Node_Str",maex);
  }
  while (isRunning()) {
    CircularElement element=null;
    try {
      element=queues.spill.take();
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
        continue;
      }
 else {
        return;
      }
    }
    if (!isRunning()) {
      return;
    }
    if (element == SENTINEL) {
      break;
    }
    final Channel.ID channel=enumerator.next();
    channelIDs.add(channel);
    LOG.debug("String_Node_Str" + channel.toString() + '.');
    final ChannelWriter writer=ioManager.createChannelWriter(channel,writeBuffers);
    LOG.debug("String_Node_Str" + element.id + '.');
    final BufferSortableGuaranteed<K,V> buffer=element.buffer;
    final CombineValueIterator<V> iter=new CombineValueIterator<V>(buffer);
    final Collector<K,V> collector=new WriterCollector<K,V>(writer);
    int i=0;
    int stop=buffer.size() - 1;
    while (i < stop) {
      int seqStart=i;
      while (i < stop && 0 == buffer.compare(i,i + 1)) {
        i++;
      }
      if (i == seqStart) {
        buffer.writeToChannel(writer,seqStart,1);
      }
 else {
        K key=buffer.getKey(seqStart);
        iter.set(seqStart,i);
        combineStub.combine(key,iter,collector);
      }
      i++;
    }
    if (i == stop) {
      buffer.writeToChannel(writer,stop,1);
    }
    LOG.debug("String_Node_Str" + element.id + "String_Node_Str");
    writer.close();
    element.buffer.reset();
    queues.empty.add(element);
  }
  LOG.debug("String_Node_Str");
  LOG.debug("String_Node_Str");
  while (!queues.empty.isEmpty()) {
    try {
      this.memoryManager.release(queues.empty.take().buffer.unbind());
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
      }
 else {
        return;
      }
    }
  }
  if (CombiningUnilateralSortMerger.this.sortSegments != null) {
    unregisterSegmentsToBeFreedAtShutdown(CombiningUnilateralSortMerger.this.sortSegments);
    CombiningUnilateralSortMerger.this.sortSegments.clear();
  }
  try {
    while (channelIDs.size() > CombiningUnilateralSortMerger.this.maxNumFileHandles) {
      channelIDs=mergeChannelList(channelIDs,writeBuffers,this.readMemSize);
    }
    this.memoryManager.release(writeBuffers);
    unregisterSegmentsToBeFreedAtShutdown(writeBuffers);
    final List<List<MemorySegment>> readBuffers=new ArrayList<List<MemorySegment>>(channelIDs.size());
    final List<MemorySegment> allBuffers=getSegmentsForReaders(readBuffers,this.readMemSize,channelIDs.size());
    registerSegmentsToBeFreedAtShutdown(allBuffers);
    final List<ChannelAccess<?>> readers=new ArrayList<ChannelAccess<?>>(channelIDs.size());
    registerChannelsToBeRemovedAtShudown(readers);
    final Iterator<KeyValuePair<K,V>> mergeIterator=getMergingIterator(channelIDs,readBuffers,readers);
    if (CombiningUnilateralSortMerger.this.combineLastMerge) {
      KeyGroupedIterator<K,V> iter=new KeyGroupedIterator<K,V>(mergeIterator);
      setResultIterator(new CombiningIterator<K,V>(combineStub,iter));
    }
 else {
      setResultIterator(mergeIterator);
    }
  }
 catch (  MemoryAllocationException maex) {
    throw new IOException("String_Node_Str",maex);
  }
  LOG.debug("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Entry point of the thread.
 */
public void go() throws IOException {
  final Channel.Enumerator enumerator=this.ioManager.createChannelEnumerator();
  final List<MemorySegment> writeBuffers;
  List<Channel.ID> channelIDs=new ArrayList<Channel.ID>();
  try {
    writeBuffers=this.memoryManager.allocate(CombiningUnilateralSortMerger.this.parent,writeMemSize,NUM_WRITE_BUFFERS,MIN_IO_BUFFER_SIZE);
    registerSegmentsToBeFreedAtShutdown(writeBuffers);
  }
 catch (  MemoryAllocationException maex) {
    throw new IOException("String_Node_Str",maex);
  }
  while (isRunning()) {
    CircularElement element=null;
    try {
      element=queues.spill.take();
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
        continue;
      }
 else {
        return;
      }
    }
    if (!isRunning()) {
      return;
    }
    if (element == SENTINEL) {
      break;
    }
    final Channel.ID channel=enumerator.next();
    channelIDs.add(channel);
    LOG.debug("String_Node_Str" + channel.toString() + '.');
    final ChannelWriter writer=ioManager.createChannelWriter(channel,writeBuffers);
    LOG.debug("String_Node_Str" + element.id + '.');
    final BufferSortableGuaranteed<K,V> buffer=element.buffer;
    final CombineValueIterator<V> iter=new CombineValueIterator<V>(buffer);
    final Collector<K,V> collector=new WriterCollector<K,V>(writer);
    int i=0;
    int stop=buffer.size() - 1;
    while (i < stop) {
      int seqStart=i;
      while (i < stop && 0 == buffer.compare(i,i + 1)) {
        i++;
      }
      if (i == seqStart) {
        buffer.writeToChannel(writer,seqStart,1);
      }
 else {
        K key=buffer.getKey(seqStart);
        iter.set(seqStart,i);
        combineStub.combine(key,iter,collector);
      }
      i++;
    }
    if (i == stop) {
      buffer.writeToChannel(writer,stop,1);
    }
    LOG.debug("String_Node_Str" + element.id + "String_Node_Str");
    writer.close();
    element.buffer.reset();
    queues.empty.add(element);
  }
  LOG.debug("String_Node_Str");
  LOG.debug("String_Node_Str");
  while (!queues.empty.isEmpty()) {
    try {
      this.memoryManager.release(queues.empty.take().buffer.unbind());
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
      }
 else {
        return;
      }
    }
  }
  if (CombiningUnilateralSortMerger.this.sortSegments != null) {
    unregisterSegmentsToBeFreedAtShutdown(CombiningUnilateralSortMerger.this.sortSegments);
    CombiningUnilateralSortMerger.this.sortSegments.clear();
  }
  try {
    while (channelIDs.size() > CombiningUnilateralSortMerger.this.maxNumFileHandles) {
      channelIDs=mergeChannelList(channelIDs,writeBuffers,this.readMemSize);
    }
    this.memoryManager.release(writeBuffers);
    unregisterSegmentsToBeFreedAtShutdown(writeBuffers);
    if (channelIDs.isEmpty()) {
      setResultIterator(EmptyIterator.<KeyValuePair<K,V>>get());
    }
 else {
      final List<List<MemorySegment>> readBuffers=new ArrayList<List<MemorySegment>>(channelIDs.size());
      final List<MemorySegment> allBuffers=getSegmentsForReaders(readBuffers,this.readMemSize,channelIDs.size());
      registerSegmentsToBeFreedAtShutdown(allBuffers);
      final List<ChannelAccess<?>> readers=new ArrayList<ChannelAccess<?>>(channelIDs.size());
      registerChannelsToBeRemovedAtShudown(readers);
      final Iterator<KeyValuePair<K,V>> mergeIterator=getMergingIterator(channelIDs,readBuffers,readers);
      if (CombiningUnilateralSortMerger.this.combineLastMerge) {
        KeyGroupedIterator<K,V> iter=new KeyGroupedIterator<K,V>(mergeIterator);
        setResultIterator(new CombiningIterator<K,V>(combineStub,iter));
      }
 else {
        setResultIterator(mergeIterator);
      }
    }
  }
 catch (  MemoryAllocationException maex) {
    throw new IOException("String_Node_Str",maex);
  }
  LOG.debug("String_Node_Str");
}