-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Array_intersect with a single argument doesn't correctly handle …
…nulls in dictionary encoded inner arrays (#11807) Summary: Pull Request resolved: #11807 The single argument flavor of array_intersect computes the intersection of the inner arrays in an array of arrays. It currently does not correctly handle nulls in the dictionary if the inner arrays are dictionary encoded. There are 2 bugs: 1) toElementRows requires that nulls be deselected in the SelectivityVector, array_intersect does not do this when calling it on the inner arrays. This means it will attempt to use the index from the DecodedVector's indices() to get the offset and size of the null arrays, which can lead to accessing arbitrary memory as the index may point off the end of the buffers getting the size and offset, which can further lead to writing to arbitrary memory as we can write off the end of the SelectivityVector. 2) When actually doing the intersection we get the innerOffset and innerSize before checking if the inner array is null. We don't end up using these values if the inner array is null, so this just results in an error when ASAN is enabled. To fix 1) I created separate APIs for toElementRows for use with DecodedVectors and otherwise. It forces the user to pass in the nulls from the DecodedVector in addition to the indices to help avoid mistakes like this. Note that this worked in PrestoHasher because it was correctly deselecting nulls in the SelectivityVector, and in WidthBucketArray because it has default null behavior so the nulls would have been automatically deselected by the expression eval code. Reviewed By: spershin Differential Revision: D66994602 fbshipit-source-id: 1c14bfaab886e692aae09b555cd6d2971e3deb72
- Loading branch information
1 parent
1bd480e
commit 4cffa4b
Showing
5 changed files
with
59 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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