Michael Smith has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/24893


Change subject: IMPALA-15376: Fix SIGABRT in AnalyticEvalNode::GetNext on empty 
window_tuples_
......................................................................

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 (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)
---
M be/src/exec/analytic-eval-node.cc
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/93/24893/1
--
To view, visit http://gerrit.cloudera.org:8080/24893
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic17c5a6ea4cfada1faf7a1715aa83489c2db7658
Gerrit-Change-Number: 24893
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Smith <[email protected]>

Reply via email to