[BugFix] Fix nestloop join crash on const build/probe columns#74952
Closed
Wenjun7J wants to merge 1 commit into
Closed
[BugFix] Fix nestloop join crash on const build/probe columns#74952Wenjun7J wants to merge 1 commit into
Wenjun7J wants to merge 1 commit into
Conversation
The pipeline nestloop-join permute path (NLJoinProbeOperator::_permute_probe_row and _permute_left_join) copies columns via Column::append / append_value_multiple_times, which down_cast the source to the concrete column type. In release builds down_cast is an unchecked static_cast, so a ConstColumn reaching the permute path is type-confused as the destination column type (e.g. BinaryColumn) and its internal pointers are read from unrelated memory, causing a wild-pointer dereference and SIGSEGV (e.g. PC in BinaryColumnBase::append, fault at a near-null address). This is reachable for degenerate nestloop plans, e.g. a constant inline view / CTE feeding the build or probe side of a cross join. The legacy non-pipeline CrossJoinNode guards every append with is_constant() checks; the pipeline operator (introduced in StarRocks#9430) never carried that protection over. Materialize const columns at the build and probe entry points so the permute code never sees a ConstColumn, matching the existing convention used at the local exchange source (StarRocks#43403). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I'm doing:
A BE crashes with
SIGSEGVwhile running a nested-loop join. The PC is inBinaryColumnBase<uint32>::append(const Column&, size_t, size_t)and the faultaddress is near-null, e.g.:
Root cause: the pipeline nestloop-join permute path
(
NLJoinProbeOperator::_permute_probe_row/_permute_left_join) copies columnsthrough
Column::append/append_value_multiple_times, whichdown_castthesource to the concrete column type. In release builds
down_castis an uncheckedstatic_cast, so aConstColumnthat reaches the permute path is type-confusedas the destination column type (e.g.
BinaryColumn). Its_offsets/_bytesare then read from unrelated memory, producing a wild pointer and a SIGSEGV at a
near-null address.
This is reachable for degenerate nestloop plans where a constant inline view / CTE
feeds the build or probe side of a cross join (the equi-keys collapse to constant
predicate pushdown, so the join degrades to a nestloop join with a constant side).
The legacy non-pipeline
CrossJoinNodeguards every append withis_constant()branches; the pipeline operator (introduced in #9430) never carried that protection
over, and there is no single chokepoint that guarantees const columns are
materialized before the join.
What I'm doing:
Materialize const columns at the nestloop-join build and probe entry points
(
NLJoinBuildOperator::push_chunkandNLJoinProbeOperator::push_chunk) viaChunk::unpack_and_duplicate_const_columns(), so the permute code never sees aConstColumn. This mirrors the existing convention added at the local exchangesource operator (#43403) for the same class of bug.
What type of PR is this:
Status
Warning
Draft. Pending validation on a build environment:
Does this PR entail a change in behavior?
identical to their materialized form.)
🤖 Generated with Claude Code