Program: 88375
Project: 88375
Buggy source:
/** 
 * @param channelIDs
 * @param ioMemorySize
 * @return The ID of the channel that holds the merged data of all input channels.
 */
protected Channel.ID mergeChannels(List<Channel.ID> channelIDs,int ioMemorySize){
  List<Iterator<KeyValuePair<K,V>>> iterators=new ArrayList<Iterator<KeyValuePair<K,V>>>(channelIDs.size());
  final int ioMemoryPerChannel=ioMemorySize / (channelIDs.size() + 2);
  for (  Channel.ID id : channelIDs) {
    Collection<MemorySegment> inputSegments;
    final ChannelReader reader;
    try {
      inputSegments=memoryManager.allocate(this.parent,1,ioMemoryPerChannel);
      freeSegmentsAtShutdown(inputSegments);
      reader=ioManager.createChannelReader(id,inputSegments);
    }
 catch (    MemoryAllocationException mae) {
      throw new RuntimeException("String_Node_Str",mae);
    }
catch (    ServiceException se) {
      throw new RuntimeException("String_Node_Str",se);
    }
    final Iterator<KeyValuePair<K,V>> iterator=new KVReaderIterator<K,V>(reader,keySerialization,valueSerialization,memoryManager,true);
    iterators.add(iterator);
  }
  MergeIterator<K,V> mi=new MergeIterator<K,V>(iterators,keyComparator);
  KeyGroupedIterator<K,V> groupedIter=new KeyGroupedIterator<K,V>(mi);
  final Channel.Enumerator enumerator=ioManager.createChannelEnumerator();
  final Channel.ID mergedChannelID=enumerator.next();
  Collection<MemorySegment> outputSegments;
  ChannelWriter writer;
  try {
    outputSegments=memoryManager.allocate(this.parent,2,ioMemoryPerChannel);
    freeSegmentsAtShutdown(outputSegments);
    writer=ioManager.createChannelWriter(mergedChannelID,outputSegments);
  }
 catch (  MemoryAllocationException mae) {
    throw new RuntimeException("String_Node_Str",mae);
  }
catch (  ServiceException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  WriterCollector<K,V> collector=new WriterCollector<K,V>(writer);
  while (groupedIter.nextKey()) {
    this.combineStub.combine(groupedIter.getKey(),groupedIter.getValues(),collector);
  }
  try {
    outputSegments=writer.close();
  }
 catch (  ServiceException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  memoryManager.release(outputSegments);
  return mergedChannelID;
}

Fixed version (ground truth):
/** 
 * @param channelIDs
 * @param ioMemorySize
 * @return The ID of the channel that holds the merged data of all input channels.
 */
protected Channel.ID mergeChannels(List<Channel.ID> channelIDs,int ioMemorySize){
  List<Iterator<KeyValuePair<K,V>>> iterators=new ArrayList<Iterator<KeyValuePair<K,V>>>(channelIDs.size());
  final int ioMemoryPerChannel=ioMemorySize / (channelIDs.size() + 2);
  for (  Channel.ID id : channelIDs) {
    final ChannelReader reader;
    try {
      inputSegments=memoryManager.allocate(this.parent,1,ioMemoryPerChannel);
      freeSegmentsAtShutdown(inputSegments);
      reader=ioManager.createChannelReader(id,inputSegments);
    }
 catch (    MemoryAllocationException mae) {
      throw new RuntimeException("String_Node_Str",mae);
    }
catch (    ServiceException se) {
      throw new RuntimeException("String_Node_Str",se);
    }
    final Iterator<KeyValuePair<K,V>> iterator=new KVReaderIterator<K,V>(reader,keySerialization,valueSerialization,memoryManager,true);
    iterators.add(iterator);
  }
  MergeIterator<K,V> mi=new MergeIterator<K,V>(iterators,keyComparator);
  KeyGroupedIterator<K,V> groupedIter=new KeyGroupedIterator<K,V>(mi);
  final Channel.Enumerator enumerator=ioManager.createChannelEnumerator();
  final Channel.ID mergedChannelID=enumerator.next();
  ChannelWriter writer;
  try {
    outputSegments=memoryManager.allocate(this.parent,2,ioMemoryPerChannel);
    freeSegmentsAtShutdown(outputSegments);
    writer=ioManager.createChannelWriter(mergedChannelID,outputSegments);
  }
 catch (  MemoryAllocationException mae) {
    throw new RuntimeException("String_Node_Str",mae);
  }
catch (  ServiceException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  WriterCollector<K,V> collector=new WriterCollector<K,V>(writer);
  while (groupedIter.nextKey()) {
    this.combineStub.combine(groupedIter.getKey(),groupedIter.getValues(),collector);
  }
  try {
    outputSegments=writer.close();
  }
 catch (  ServiceException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  memoryManager.release(outputSegments);
  return mergedChannelID;
}