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

bitarray: fix a bug in the right shift logic #36715

Merged
merged 1 commit into from Apr 11, 2019

Conversation

Projects
4 participants
@knz
Copy link
Member

commented Apr 10, 2019

Fixes #36606.

When shifting by a number of bits smaller than 64, the resulting word
array was not canonical - it would contain leftover bits from the
original value in the last slot, beyond lastBitsUsed.

This patch ensures these bits get cleared.

Release note (bug fix): CockroachDB now computes the result of
shifting bit arrays to the right properly and avoids generating
invalid bit arrays.

bitarray: fix a bug in the right shift logic
When shifting by a number of bits smaller than 64, the resulting word
array was not canonical - it would contain leftover bits from the
original value in the last slot, beyond `lastBitsUsed`.

This patch ensures these bits get cleared.

Release note (bug fix): CockroachDB now computes the result of
shifting bit arrays to the right properly and avoids generating
invalid bit arrays.

@knz knz requested a review from mjibson Apr 10, 2019

@knz knz added this to Triage in (DEPRECATED) SQL Front-end, Lang & Semantics via automation Apr 10, 2019

@cockroach-teamcity

This comment has been minimized.

Copy link
Member

commented Apr 10, 2019

This change is Reviewable

@knz

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2019

@mjibson I have modified the bit array tests to check that the other bit array operators also round trip properly.

@jordanlewis this is a logic error and is thus candidate for a backport. Should I issue the backport PR right away or wait until after the release?

@jordanlewis

This comment has been minimized.

Copy link
Member

commented Apr 10, 2019

Backporting now is fine.

@knz

This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2019

TFYR!

bors r+

craig bot pushed a commit that referenced this pull request Apr 11, 2019

Merge #36715
36715: bitarray: fix a bug in the right shift logic r=knz a=knz

Fixes #36606.

When shifting by a number of bits smaller than 64, the resulting word
array was not canonical - it would contain leftover bits from the
original value in the last slot, beyond `lastBitsUsed`.

This patch ensures these bits get cleared.

Release note (bug fix): CockroachDB now computes the result of
shifting bit arrays to the right properly and avoids generating
invalid bit arrays.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig

This comment has been minimized.

Copy link

commented Apr 11, 2019

Build succeeded

@craig craig bot merged commit 2719624 into cockroachdb:master Apr 11, 2019

3 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.