You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2019/09/25 22:30:25 UTC

[impala] 03/03: IMPALA-8969: Grouping aggregator can cause segmentation fault when doing multiple aggregations

This is an automated email from the ASF dual-hosted git repository.

stakiar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit ab975c95171bdc0892326133a63e467398d5bbe2
Author: Zoltan Borok-Nagy <bo...@cloudera.com>
AuthorDate: Tue Sep 24 12:14:34 2019 +0200

    IMPALA-8969: Grouping aggregator can cause segmentation fault when doing multiple aggregations
    
    Grouping aggregator always tried to serialize the 0th tuple regardless
    of the aggregation index. This could lead to a segmentation fault
    because the 0th tuple might be null.
    
    Testing:
    Added a query that triggers the error to multiple-distinct-aggs.test
    
    Change-Id: I7acdd40c63166cd4986e546a992c0816f94823d5
    Reviewed-on: http://gerrit.cloudera.org:8080/14290
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exec/grouping-aggregator-ir.cc                  |  2 +-
 .../queries/QueryTest/multiple-distinct-aggs.test      | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/be/src/exec/grouping-aggregator-ir.cc b/be/src/exec/grouping-aggregator-ir.cc
index 9f7c399..d3c7f1a 100644
--- a/be/src/exec/grouping-aggregator-ir.cc
+++ b/be/src/exec/grouping-aggregator-ir.cc
@@ -201,7 +201,7 @@ Status GroupingAggregator::AddBatchStreamingImpl(int agg_idx, bool needs_seriali
 ret:
   if (needs_serialize) {
     FOREACH_ROW(out_batch, 0, out_batch_iter) {
-      AggFnEvaluator::Serialize(agg_fn_evals_, out_batch_iter.Get()->GetTuple(0));
+      AggFnEvaluator::Serialize(agg_fn_evals_, out_batch_iter.Get()->GetTuple(agg_idx));
     }
   }
 
diff --git a/testdata/workloads/functional-query/queries/QueryTest/multiple-distinct-aggs.test b/testdata/workloads/functional-query/queries/QueryTest/multiple-distinct-aggs.test
index 5ae87d8..ab7fd4e 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/multiple-distinct-aggs.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/multiple-distinct-aggs.test
@@ -436,4 +436,20 @@ where 1 not in
 BIGINT,BIGINT,BIGINT
 ---- RESULTS
 1464556,1500000,2406
-====
\ No newline at end of file
+====
+---- QUERY
+# IMPALA-8969: Grouping aggregator can cause segmentation fault when doing multiple
+# aggregations.
+select sum(len_orderkey), sum(len_comment)
+from (
+  select
+    length(group_concat(distinct cast(l_orderkey as string))) len_orderkey,
+    length(group_concat(distinct(l_comment))) len_comment
+    from tpch.lineitem
+    group by l_comment
+  ) v
+---- TYPES
+BIGINT,BIGINT
+---- RESULTS
+43737923,135857609
+====