[BugFix] fix asan crash in array_map (backport #51966) #52008
Merged
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:
What I'm doing:
Fixes https://github.com/StarRocks/StarRocksTest/issues/8699
root cause
this crash is because we can't find the slot id in chunk and then can't pass the DCHECK inside it.
In fact, for
array_map(x -> array_map(x->x+100, x),[[1,23],[4,3,2]])
, the lambda exprx->array_map(x->x+100,x)
only depends on the lambda argument, not on other capture columns.
capture_slot_ids
should be empty here.But the argument of the inner lambda expr
array_map(x->x+100,x)
is mistakenly regarded as the capture column and be added into the capture_slot_ids.LambdaFunction::get_slot_ids
to get the capture columns' slot id, and the result of this interface incorrectly includes the lambda argument id. this is the root cause of the above crash.extract_outer_common_exprs
, we need to know the maximum slot_id used in the currentExpr
tree. The rewritten ColumnRef will allocate slot_id from themax_used_slot_id + 1
. Here we need to consider the slot_id used by the lambda arguments. Currently,LambdaFunction:get_slot_ids
is also used to get the result.Obviously, these two places rely on
LambdaFunction::get_slot_ids
and there is a conflict. One needs to consider the lambda argument and the other does not.To solve this problem
LambdaFunction::get_slot_ids
, and only include the capture columns' slot id in the return resultExpr::for_each_slot_id
to traverse all slot ids in a certain Expr tree.What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request #51966 done by [Mergify](https://mergify.com). ## Why I'm doing:
What I'm doing:
Fixes https://github.com/StarRocks/StarRocksTest/issues/8699
root cause
this crash is because we can't find the slot id in chunk and then can't pass the DCHECK inside it.
In fact, for
array_map(x -> array_map(x->x+100, x),[[1,23],[4,3,2]])
, the lambda exprx->array_map(x->x+100,x)
only depends on the lambda argument, not on other capture columns.
capture_slot_ids
should be empty here.But the argument of the inner lambda expr
array_map(x->x+100,x)
is mistakenly regarded as the capture column and be added into the capture_slot_ids.LambdaFunction::get_slot_ids
to get the capture columns' slot id, and the result of this interface incorrectly includes the lambda argument id. this is the root cause of the above crash.extract_outer_common_exprs
, we need to know the maximum slot_id used in the currentExpr
tree. The rewritten ColumnRef will allocate slot_id from themax_used_slot_id + 1
. Here we need to consider the slot_id used by the lambda arguments. Currently,LambdaFunction:get_slot_ids
is also used to get the result.Obviously, these two places rely on
LambdaFunction::get_slot_ids
and there is a conflict. One needs to consider the lambda argument and the other does not.To solve this problem
LambdaFunction::get_slot_ids
, and only include the capture columns' slot id in the return resultExpr::for_each_slot_id
to traverse all slot ids in a certain Expr tree.What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist: