Program: 92791
Project: 92791
Buggy source:
/** 
 * Represent the series of events with specified durations
 * @param item
 * @param rect - The container rectangle to be colored to different states
 * @param time0 - Base time of all events - start of visible window
 * @param time1 - End time of visible events - end time of visible window
 * @param endTime - End time of all events - may not be visible in selected visible window
 * @param selectedTime
 * @param gc
 */
void drawItemDataDurations(Item item,Rectangle rect,long time0,long time1,long endTime,long selectedTime,GC gc){
  if (rect.isEmpty())   return;
  if (time1 <= time0) {
    gc.setBackground(_colors.getBkColor(false,false,false));
    gc.fillRectangle(rect);
    return;
  }
  Utils.init(_rect1,rect);
  boolean selected=item._selected;
  double pixelsPerNanoSec=(rect.width <= RIGHT_MARGIN) ? 0 : (double)(rect.width - RIGHT_MARGIN) / (time1 - time0);
  boolean group=item instanceof GroupItem;
  if (group) {
  }
 else   if (item instanceof TraceItem) {
    ITmfTimeAnalysisEntry trace=((TraceItem)item)._trace;
    double x0=rect.x;
    long maxDuration=(_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();
    Iterator<ITimeEvent> iterator=trace.getTraceEventsIterator(_timeProvider.getTime0(),_timeProvider.getTime1(),maxDuration);
    _rect1.y+=3;
    _rect1.height-=6;
    int xEnd=rect.x + rect.width;
    fillSpace(rect,gc,selected);
    if (iterator.hasNext()) {
      ITimeEvent currEvent=iterator.next();
      ITimeEvent nextEvent=null;
      long currEventTime=currEvent.getTime();
      long currEventDuration=currEvent.getDuration();
      long nextEventTime=currEventTime;
      double step=(double)((currEventTime - time0) * pixelsPerNanoSec);
      x0=rect.x + step;
      double x1=-1;
      int idx=1;
      double xNext=0;
      while (null != currEvent) {
        boolean stopped=false;
        currEventDuration=currEvent.getDuration();
        if (iterator.hasNext()) {
          nextEvent=iterator.next();
          nextEventTime=nextEvent.getTime();
          idx++;
        }
 else         if (stopped) {
          nextEvent=null;
          nextEventTime=time1;
        }
 else {
          nextEvent=null;
          nextEventTime=endTime;
        }
        xNext=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
        if (currEventDuration < 0) {
          x1=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
        }
 else         if (currEventDuration == 0) {
          x1=x0;
        }
 else {
          x1=x0 + (double)((currEventDuration) * pixelsPerNanoSec);
        }
        if (currEventDuration != 0) {
          x1=x1 > xNext ? xNext : x1;
        }
        if (x1 >= rect.x && x0 <= xEnd) {
          if (currEventDuration != 0) {
            x0=(double)(x0 >= rect.x ? x0 : rect.x);
            _rect1.width=(int)Math.ceil(x1 <= xEnd ? x1 : xEnd) - (int)x0;
          }
 else {
            _rect1.width=1;
          }
          _rect1.width=Math.max(_minimumItemWidth,_rect1.width);
          _rect1.x=(int)x0;
          boolean timeSelected=currEventTime <= selectedTime && selectedTime < nextEventTime;
          utilImpl.drawState(_colors,currEvent,_rect1,gc,selected,false,timeSelected);
          _rect1.x+=_rect1.width;
          x0=_rect1.x;
        }
        currEvent=nextEvent;
        currEventTime=nextEventTime;
        x0=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
      }
    }
  }
  int x=rect.x + (int)((double)(selectedTime - time0) * pixelsPerNanoSec);
  if (x >= rect.x && x < rect.x + rect.width) {
    gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));
    if (group)     gc.drawLine(x,rect.y + rect.height - 1,x,rect.y + rect.height);
 else     gc.drawLine(x,rect.y,x,rect.y + rect.height);
  }
}

Fixed version (ground truth):
/** 
 * Represent the series of events with specified durations
 * @param item
 * @param rect - The container rectangle to be colored to different states
 * @param time0 - Base time of all events - start of visible window
 * @param time1 - End time of visible events - end time of visible window
 * @param endTime - End time of all events - may not be visible in selected visible window
 * @param selectedTime
 * @param gc
 */
void drawItemDataDurations(Item item,Rectangle rect,long time0,long time1,long endTime,long selectedTime,GC gc){
  if (rect.isEmpty())   return;
  if (time1 <= time0) {
    gc.setBackground(_colors.getBkColor(false,false,false));
    gc.fillRectangle(rect);
    return;
  }
  Utils.init(_rect1,rect);
  boolean selected=item._selected;
  double pixelsPerNanoSec=(rect.width <= RIGHT_MARGIN) ? 0 : (double)(rect.width - RIGHT_MARGIN) / (time1 - time0);
  boolean group=item instanceof GroupItem;
  if (group) {
  }
 else   if (item instanceof TraceItem) {
    ITmfTimeAnalysisEntry trace=((TraceItem)item)._trace;
    double x0=rect.x;
    long maxDuration=(_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();
    Iterator<ITimeEvent> iterator=trace.getTraceEventsIterator(_timeProvider.getTime0(),_timeProvider.getTime1(),maxDuration);
    _rect1.y+=3;
    _rect1.height-=6;
    int xEnd=rect.x + rect.width;
    fillSpace(rect,gc,selected);
    if (iterator.hasNext()) {
      ITimeEvent currEvent=iterator.next();
      ITimeEvent nextEvent=null;
      long currEventTime=currEvent.getTime();
      long currEventDuration=currEvent.getDuration();
      long nextEventTime=currEventTime;
      double step=(double)((currEventTime - time0) * pixelsPerNanoSec);
      x0=rect.x + step;
      double x1=-1;
      double xNext=0;
      while (null != currEvent) {
        boolean stopped=false;
        currEventDuration=currEvent.getDuration();
        if (iterator.hasNext()) {
          nextEvent=iterator.next();
          nextEventTime=nextEvent.getTime();
        }
 else         if (stopped) {
          nextEvent=null;
          nextEventTime=time1;
        }
 else {
          nextEvent=null;
          nextEventTime=endTime;
        }
        xNext=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
        if (currEventDuration < 0) {
          x1=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
        }
 else         if (currEventDuration == 0) {
          x1=x0;
        }
 else {
          x1=x0 + (double)((currEventDuration) * pixelsPerNanoSec);
        }
        if (currEventDuration != 0) {
          x1=x1 > xNext ? xNext : x1;
        }
        if (x1 >= rect.x && x0 <= xEnd) {
          if (currEventDuration != 0) {
            x0=(double)(x0 >= rect.x ? x0 : rect.x);
            _rect1.width=(int)((x1 <= xEnd ? x1 : xEnd) - x0);
          }
 else {
            _rect1.width=1;
          }
          _rect1.width=Math.max(_minimumItemWidth,_rect1.width);
          _rect1.x=(int)x0;
          boolean timeSelected=currEventTime <= selectedTime && selectedTime < nextEventTime;
          utilImpl.drawState(_colors,currEvent,_rect1,gc,selected,false,timeSelected);
          _rect1.x+=_rect1.width;
          x0=_rect1.x;
        }
        currEvent=nextEvent;
        currEventTime=nextEventTime;
        x0=rect.x + (double)((nextEventTime - time0) * pixelsPerNanoSec);
      }
    }
  }
  int x=rect.x + (int)((double)(selectedTime - time0) * pixelsPerNanoSec);
  if (x >= rect.x && x < rect.x + rect.width) {
    gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));
    if (group)     gc.drawLine(x,rect.y + rect.height - 1,x,rect.y + rect.height);
 else     gc.drawLine(x,rect.y,x,rect.y + rect.height);
  }
}