Program: 25375
Project: 25375
Buggy source:
private static void findCubePositions(ASTNode ast,List<CubeQueryInfo> cubeQueries,String originalQuery) throws SemanticException {
  int child_count=ast.getChildCount();
  if (ast.getToken() != null) {
    if (ast.getChild(0) != null) {
      CubeGrillDriver.LOG.debug("String_Node_Str" + ast.getChild(0) + "String_Node_Str"+ ((ASTNode)ast.getChild(0)).getToken().getType());
    }
    if (ast.getToken().getType() == HiveParser.TOK_QUERY && ((ASTNode)ast.getChild(0)).getToken().getType() == HiveParser.KW_CUBE) {
      CubeGrillDriver.LOG.debug("String_Node_Str");
      CubeQueryInfo cqi=new CubeQueryInfo();
      cqi.cubeAST=ast;
      if (ast.getParent() != null) {
        ASTNode parent=(ASTNode)ast.getParent();
        cqi.startPos=ast.getCharPositionInLine();
        int ci=ast.getChildIndex();
        if (parent.getToken() == null || parent.getToken().getType() == HiveParser.TOK_EXPLAIN) {
          cqi.endPos=originalQuery.length();
        }
 else         if (parent.getChildCount() > ci + 1) {
          if (parent.getToken().getType() == HiveParser.TOK_SUBQUERY) {
            cqi.endPos=getEndPos(originalQuery,parent.getChild(ci + 1).getCharPositionInLine(),"String_Node_Str");
            ;
          }
 else           if (parent.getToken().getType() == HiveParser.TOK_UNION) {
            cqi.endPos=getEndPos(originalQuery,parent.getChild(ci + 1).getCharPositionInLine() - 1,"String_Node_Str");
          }
 else {
            CubeGrillDriver.LOG.warn("String_Node_Str" + ast.dump());
            throw new SemanticException("String_Node_Str");
          }
        }
 else {
          cqi.endPos=getEndPos(originalQuery,parent.getParent().getChild(1).getCharPositionInLine(),"String_Node_Str","String_Node_Str");
        }
      }
      CubeGrillDriver.LOG.debug("String_Node_Str" + cqi + "String_Node_Str"+ originalQuery.substring(cqi.startPos,cqi.endPos));
      cubeQueries.add(cqi);
    }
 else {
      for (int child_pos=0; child_pos < child_count; ++child_pos) {
        findCubePositions((ASTNode)ast.getChild(child_pos),cubeQueries,originalQuery);
      }
    }
  }
 else {
    CubeGrillDriver.LOG.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
private static void findCubePositions(ASTNode ast,List<CubeQueryInfo> cubeQueries,String originalQuery) throws SemanticException {
  int child_count=ast.getChildCount();
  if (ast.getToken() != null) {
    if (ast.getChild(0) != null) {
      CubeGrillDriver.LOG.debug("String_Node_Str" + ast.getChild(0) + "String_Node_Str"+ ((ASTNode)ast.getChild(0)).getToken().getType());
    }
    if (ast.getToken().getType() == HiveParser.TOK_QUERY && ((ASTNode)ast.getChild(0)).getToken().getType() == HiveParser.KW_CUBE) {
      CubeGrillDriver.LOG.debug("String_Node_Str");
      CubeQueryInfo cqi=new CubeQueryInfo();
      cqi.cubeAST=ast;
      if (ast.getParent() != null) {
        ASTNode parent=(ASTNode)ast.getParent();
        cqi.startPos=ast.getCharPositionInLine();
        int ci=ast.getChildIndex();
        if (parent.getToken() == null || parent.getToken().getType() == HiveParser.TOK_EXPLAIN || parent.getToken().getType() == HiveParser.TOK_CREATETABLE) {
          cqi.endPos=originalQuery.length();
        }
 else         if (parent.getChildCount() > ci + 1) {
          if (parent.getToken().getType() == HiveParser.TOK_SUBQUERY) {
            cqi.endPos=getEndPos(originalQuery,parent.getChild(ci + 1).getCharPositionInLine(),"String_Node_Str");
            ;
          }
 else           if (parent.getToken().getType() == HiveParser.TOK_UNION) {
            cqi.endPos=getEndPos(originalQuery,parent.getChild(ci + 1).getCharPositionInLine() - 1,"String_Node_Str");
          }
 else {
            CubeGrillDriver.LOG.warn("String_Node_Str" + ast.dump());
            throw new SemanticException("String_Node_Str");
          }
        }
 else {
          CubeGrillDriver.LOG.debug("String_Node_Str");
          cqi.endPos=getEndPos(originalQuery,parent.getParent().getChild(1).getCharPositionInLine(),"String_Node_Str","String_Node_Str");
        }
      }
      CubeGrillDriver.LOG.debug("String_Node_Str" + cqi + "String_Node_Str"+ originalQuery.substring(cqi.startPos,cqi.endPos));
      cubeQueries.add(cqi);
    }
 else {
      for (int child_pos=0; child_pos < child_count; ++child_pos) {
        findCubePositions((ASTNode)ast.getChild(child_pos),cubeQueries,originalQuery);
      }
    }
  }
 else {
    CubeGrillDriver.LOG.warn("String_Node_Str");
  }
}