Skip to content

fix: bitops_family crash fixed #4989

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

Merged
merged 7 commits into from
Apr 28, 2025
Merged

fix: bitops_family crash fixed #4989

merged 7 commits into from
Apr 28, 2025

Conversation

vyavdoshenko
Copy link
Contributor

fixes: #4988

@vyavdoshenko vyavdoshenko self-assigned this Apr 24, 2025
Comment on lines 732 to 737
if (last_byte_offset >= total_bytes) {
return {};
}

int32_t byte_index = GetByteIndex(offset);
if (byte_index >= total_bytes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (last_byte_offset >= total_bytes) {
return {};
}
int32_t byte_index = GetByteIndex(offset);
if (byte_index >= total_bytes) {
if (last_byte_offset >= total_bytes) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sufficient. We check the expression above GetByteIndex(attr_.offset + attr_.encoding_bit_size - 1);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kostasrim
This is not enough.
I updated the condition, please take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kostasrim
Please, take a look again.

Comment on lines 746 to 749
int32_t lsb_byte_index = GetByteIndex(lsb);
if (lsb_byte_index >= total_bytes) {
return {};
}
Copy link
Contributor

@kostasrim kostasrim Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to check again here. The above check is sufficient -- we can remove this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@vyavdoshenko vyavdoshenko requested a review from kostasrim April 24, 2025 14:27
kostasrim
kostasrim previously approved these changes Apr 25, 2025
Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Small comment

@@ -728,17 +728,25 @@ ResultType Get::ApplyTo(Overflow ov, const string* bitfield) {
const size_t offset = attr_.offset;
auto last_byte_offset = GetByteIndex(attr_.offset + attr_.encoding_bit_size - 1);

if (GetByteIndex(offset) >= total_bytes && attr_.encoding_bit_size > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (GetByteIndex(offset) >= total_bytes && attr_.encoding_bit_size > 0) {
if (GetByteIndex(offset) >= total_bytes) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because attr_.encoding_bit_size > 0 is always true. (See how we parse the arguments for this command)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@vyavdoshenko vyavdoshenko merged commit 59a347d into main Apr 28, 2025
10 checks passed
@vyavdoshenko vyavdoshenko deleted the bobik/bitops_crash_fix branch April 28, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault with BITFIELD command
2 participants