You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by mi...@apache.org on 2026/09/22 18:41:43 UTC

(impala) 02/02: IMPALA-15376: Fix SIGABRT in AnalyticEvalNode::GetNext on empty window_tuples_

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

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

commit efdd0713f37a46aa7161902c7410059a25cdd517
Author: Michael Smith <mi...@cloudera.com>
AuthorDate: Thu Sep 17 16:29:26 2026 -0700

    IMPALA-15376: Fix SIGABRT in AnalyticEvalNode::GetNext on empty window_tuples_
    
    AnalyticEvalNode::GetNext() unconditionally called
    window_tuples_.front() when deciding whether to transfer the prev
    tuple pool to the output batch. window_tuples_ can legitimately be
    empty at that point (e.g. right after all window tuples have been
    popped, or when prev_pool_last_window_idx_ was recorded as the -1
    sentinel), so calling front() on the empty deque is undefined
    behavior. Under _GLIBCXX_ASSERTIONS on GCC 15+ (enabled whenever
    __OPTIMIZE__ is unset, e.g. -O0/UBSAN/DEBUG_NOOPT builds) this
    aborts the process.
    
    Reproduced by a query combining an analytic/window function with an
    outer ORDER BY + LIMIT, e.g.:
    
      select * from (
        select l_partkey, l_quantity, l_orderkey,
          rank() over (partition by l_partkey, l_quantity
                       order by l_orderkey desc) rk
        from lineitem) dt
      order by l_partkey, l_quantity, l_orderkey, rk
      limit 10
    
    which plans to a local TopNNode pulling rows from AnalyticEvalNode via
    GetNext() in TopNNode::Open().
    
    Guard the front() access by short-circuiting when window_tuples_ is
    empty, since an empty window_tuples_ means nothing remains that could
    still reference prev_tuple_pool_, so it's always safe to transfer.
    
    Change-Id: Ic17c5a6ea4cfada1faf7a1715aa83489c2db7658
    Assisted-by: Claude Sonnet 5 (GitHub Copilot)
    Reviewed-on: http://gerrit.cloudera.org:8080/24893
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exec/analytic-eval-node.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/be/src/exec/analytic-eval-node.cc b/be/src/exec/analytic-eval-node.cc
index 1ff5d5dae..c5ef633c4 100644
--- a/be/src/exec/analytic-eval-node.cc
+++ b/be/src/exec/analytic-eval-node.cc
@@ -823,7 +823,8 @@ Status AnalyticEvalNode::GetNext(RuntimeState* state, RowBatch* row_batch, bool*
     *eos = true;
   } else if (prev_pool_last_result_idx_ != -1 &&
       prev_pool_last_result_idx_ < input_stream_->rows_returned() &&
-      prev_pool_last_window_idx_ < window_tuples_.front().first) {
+      (window_tuples_.empty() ||
+       prev_pool_last_window_idx_ < window_tuples_.front().first)) {
     // Transfer resources to the output row batch if enough have accumulated and they're
     // no longer needed by output rows to be returned later.
     VLOG_FILE << id() << " Transfer prev pool to output batch, "