Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrapping of 0-length vector in element_at and subscript functions #3284

Closed
wants to merge 1 commit into from

Conversation

kagamiori
Copy link
Contributor

@kagamiori kagamiori commented Nov 17, 2022

Summary:
Expression fuzzer found a bug in element_at() and subscript() functions when
the input vector has a 0-length element vector and there are unselected rows
of this evaluation: #3216. In this situation, SubscriptImpl builds up an indices
where unselected rows point to 0 (i.e., default value) and use it to wrap the 0-
length element vector via BaseVector::wrapInDictionary. DictionaryVector::setInternalState()
checks that the index pointed to by indices is less than the length of the
vector being wrapped, which are both 0 in this case. Hence the error happens.

This diff fixes this bug by directly creating a null vector when the input element
vector has 0 length, instead of wrapping it in a dictionary.

Differential Revision: D41357753

@netlify
Copy link

netlify bot commented Nov 17, 2022

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 7e42770
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/638a34e7dcc5ef0008267636

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Nov 17, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D41357753

kagamiori added a commit to kagamiori/velox that referenced this pull request Nov 21, 2022
…facebookincubator#3284)

Summary:
Pull Request resolved: facebookincubator#3284

Expression fuzzer found a bug in element_at() and subscript() functions when the input vector has a 0-length element vector and there are unselected rows of this evaluation: facebookincubator#3216. In this situation, SubscriptImpl builds up an `indices` where unselected rows point to 0 (i.e., default value) and use it to wrap the 0-length element vector via BaseVector::wrapInDictionary. DictionaryVector<T>::setInternalState() checks that the index pointed to by `indices` is less than the length of the vector being wrapped, which are both 0 in this case. Hence the error happens.

This diff fixes this bug by directly creating a null vector when the input element vector has 0 length, instead of wrapping it in a dictionary.

Differential Revision: D41357753

fbshipit-source-id: e7c8d11b0cf84d7b3a72ccc79ec4234908a6b2ce
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D41357753

…facebookincubator#3284)

Summary:
Pull Request resolved: facebookincubator#3284

Expression fuzzer found a bug in element_at() and subscript() functions when the input vector has a 0-length element vector and there are unselected rows of this evaluation: facebookincubator#3216. In this situation, SubscriptImpl builds up an `indices` where unselected rows point to 0 (i.e., default value) and use it to wrap the 0-length element vector via BaseVector::wrapInDictionary. DictionaryVector<T>::setInternalState() checks that the index pointed to by `indices` is less than the length of the vector being wrapped, which are both 0 in this case. Hence the error happens.

This diff fixes this bug by directly creating a null vector when the input element vector has 0 length, instead of wrapping it in a dictionary.

Reviewed By: bikramSingh91

Differential Revision: D41357753

fbshipit-source-id: aa84b67dfbcace5a12e97fc61163e92ec7f21663
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D41357753

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Dec 14, 2022
Summary:
facebookincubator#3284 changed the behavior of subscript operators so if an array is empty any subscript access (regardless of value) returns NULL.

The way it was written, this only applies if all the arrays in a batch are empty.  This change makes it so it applies consistently if only a subset of arrays are empty.

This inconsistency in behavior was identified in facebookincubator#3490

Differential Revision: D42021583

fbshipit-source-id: b94746aeb4748249b11ffd0b1fffbf5ce4c227b7
facebook-github-bot pushed a commit that referenced this pull request Dec 14, 2022
Summary:
Pull Request resolved: #3509

#3284 changed the behavior of subscript operators so if an array is empty any subscript access (regardless of value) returns NULL.

The way it was written, this only applies if all the arrays in a batch are empty.  This change makes it so it applies consistently if only a subset of arrays are empty.

This inconsistency in behavior was identified in #3490

Reviewed By: mbasmanova

Differential Revision: D42021583

fbshipit-source-id: e49e6a2bd8714a4e617b7e201b1ce2722551077f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants