Program: 50867
Project: 50867
Buggy source:
/** 
 * Evaluates an expression. Intended for evaluating named sets. <p>Does not modify the contents of the evaluator.
 * @param calc Compiled expression
 * @param slicerEvaluator Evaluation context for slicers
 * @param contextEvaluator Evaluation context (optional)
 * @return Result
 */
Object evaluateExp(Calc calc,RolapEvaluator slicerEvaluator,Evaluator contextEvaluator){
  int attempt=0;
  RolapEvaluator evaluator=slicerEvaluator.push();
  if (contextEvaluator != null && contextEvaluator.isEvalAxes()) {
    evaluator.setEvalAxes(true);
    evaluator.setContext(contextEvaluator.getMembers());
    evaluator.setSlicerTuples(((RolapEvaluator)contextEvaluator).getSlicerTuples());
  }
  final int savepoint=evaluator.savepoint();
  boolean dirty=batchingReader.isDirty();
  try {
    while (true) {
      evaluator.restore(savepoint);
      evaluator.setCellReader(batchingReader);
      Object preliminaryValue=calc.evaluate(evaluator);
      if (preliminaryValue instanceof TupleIterable) {
        TupleIterable iterable=(TupleIterable)preliminaryValue;
        final TupleCursor cursor=iterable.tupleCursor();
        while (cursor.forward()) {
        }
      }
      if (!phase()) {
        break;
      }
 else {
        evaluator.clearExpResultCache(false);
      }
      if (attempt++ > maxEvalDepth) {
        throw Util.newInternal("String_Node_Str" + maxEvalDepth + "String_Node_Str");
      }
    }
    if (dirty) {
      batchingReader.setDirty(true);
    }
    evaluator.restore(savepoint);
    evaluator.setCellReader(aggregatingReader);
    final Object o=calc.evaluate(evaluator);
    return o;
  }
  finally {
    evaluator.restore(savepoint);
  }
}

Fixed version (ground truth):
/** 
 * Evaluates an expression. Intended for evaluating named sets. <p>Does not modify the contents of the evaluator.
 * @param calc Compiled expression
 * @param slicerEvaluator Evaluation context for slicers
 * @param contextEvaluator Evaluation context (optional)
 * @return Result
 */
Object evaluateExp(Calc calc,RolapEvaluator slicerEvaluator,Evaluator contextEvaluator){
  int attempt=0;
  RolapEvaluator evaluator=slicerEvaluator.push();
  if (contextEvaluator != null && contextEvaluator.isEvalAxes()) {
    evaluator.setEvalAxes(true);
  }
  final int savepoint=evaluator.savepoint();
  boolean dirty=batchingReader.isDirty();
  try {
    while (true) {
      evaluator.restore(savepoint);
      evaluator.setCellReader(batchingReader);
      Object preliminaryValue=calc.evaluate(evaluator);
      if (preliminaryValue instanceof TupleIterable) {
        TupleIterable iterable=(TupleIterable)preliminaryValue;
        final TupleCursor cursor=iterable.tupleCursor();
        while (cursor.forward()) {
        }
      }
      if (!phase()) {
        break;
      }
 else {
        evaluator.clearExpResultCache(false);
      }
      if (attempt++ > maxEvalDepth) {
        throw Util.newInternal("String_Node_Str" + maxEvalDepth + "String_Node_Str");
      }
    }
    if (dirty) {
      batchingReader.setDirty(true);
    }
    evaluator.restore(savepoint);
    evaluator.setCellReader(aggregatingReader);
    final Object o=calc.evaluate(evaluator);
    return o;
  }
  finally {
    evaluator.restore(savepoint);
  }
}