Program: 88301
Project: 88301
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(UnilateralSortMerger.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=this.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;
    }
    Channel.ID channel=enumerator.next();
    channelIDs.add(channel);
    ChannelWriter writer=this.ioManager.createChannelWriter(channel,writeBuffers);
    LOG.debug("String_Node_Str" + element.id + "String_Node_Str");
    element.buffer.writeToChannel(writer);
    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 {
      memoryManager.release(queues.empty.take().buffer.unbind());
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
      }
 else {
        return;
      }
    }
  }
  if (UnilateralSortMerger.this.sortSegments != null) {
    unregisterSegmentsToBeFreedAtShutdown(UnilateralSortMerger.this.sortSegments);
    UnilateralSortMerger.this.sortSegments.clear();
  }
  try {
    while (channelIDs.size() > UnilateralSortMerger.this.maxNumFileHandles) {
      channelIDs=mergeChannelList(channelIDs,writeBuffers,this.readMemSize);
    }
    this.memoryManager.release(writeBuffers);
    unregisterSegmentsToBeFreedAtShutdown(writeBuffers);
    writeBuffers.clear();
    List<List<MemorySegment>> readBuffers=new ArrayList<List<MemorySegment>>(channelIDs.size());
    List<MemorySegment> allBuffers=getSegmentsForReaders(readBuffers,this.readMemSize,channelIDs.size());
    registerSegmentsToBeFreedAtShutdown(allBuffers);
    List<ChannelAccess<?>> readers=new ArrayList<ChannelAccess<?>>(channelIDs.size());
    registerChannelsToBeRemovedAtShudown(readers);
    setResultIterator(getMergingIterator(channelIDs,readBuffers,readers));
  }
 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(UnilateralSortMerger.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=this.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;
    }
    Channel.ID channel=enumerator.next();
    channelIDs.add(channel);
    ChannelWriter writer=this.ioManager.createChannelWriter(channel,writeBuffers);
    LOG.debug("String_Node_Str" + element.id + "String_Node_Str");
    element.buffer.writeToChannel(writer);
    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 {
      memoryManager.release(queues.empty.take().buffer.unbind());
    }
 catch (    InterruptedException iex) {
      if (isRunning()) {
        LOG.error("String_Node_Str" + "String_Node_Str");
      }
 else {
        return;
      }
    }
  }
  if (UnilateralSortMerger.this.sortSegments != null) {
    unregisterSegmentsToBeFreedAtShutdown(UnilateralSortMerger.this.sortSegments);
    UnilateralSortMerger.this.sortSegments.clear();
  }
  try {
    while (channelIDs.size() > UnilateralSortMerger.this.maxNumFileHandles) {
      channelIDs=mergeChannelList(channelIDs,writeBuffers,this.readMemSize);
    }
    this.memoryManager.release(writeBuffers);
    unregisterSegmentsToBeFreedAtShutdown(writeBuffers);
    writeBuffers.clear();
    if (channelIDs.isEmpty()) {
      setResultIterator(EmptyIterator.<KeyValuePair<K,V>>get());
    }
 else {
      LOG.debug("String_Node_Str");
      List<List<MemorySegment>> readBuffers=new ArrayList<List<MemorySegment>>(channelIDs.size());
      List<MemorySegment> allBuffers=getSegmentsForReaders(readBuffers,this.readMemSize,channelIDs.size());
      registerSegmentsToBeFreedAtShutdown(allBuffers);
      List<ChannelAccess<?>> readers=new ArrayList<ChannelAccess<?>>(channelIDs.size());
      registerChannelsToBeRemovedAtShudown(readers);
      setResultIterator(getMergingIterator(channelIDs,readBuffers,readers));
    }
  }
 catch (  MemoryAllocationException maex) {
    throw new IOException("String_Node_Str",maex);
  }
  LOG.debug("String_Node_Str");
}