Skip to content

Conversation

@zuiderkwast
Copy link
Contributor

The unit test was added in #1741. It fails when compiled with UBSAN. Using a local array like char buf[size] is undefined behaviour when size == 0. This fix just makes it size 1 in this case.

The failure I get locally:

unit/test_bitops.c:28:13: runtime error: variable length array bound evaluates to non-positive value 0

Copy link
Member

@rjd15372 rjd15372 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zuiderkwast zuiderkwast merged commit 7db01d8 into valkey-io:unstable Feb 26, 2025
49 checks passed
@zuiderkwast zuiderkwast deleted the ubsan-bitops-unit-test branch February 26, 2025 18:01
@codecov
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.02%. Comparing base (79d5047) to head (81ffec6).
Report is 2 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1786      +/-   ##
============================================
- Coverage     71.17%   71.02%   -0.15%     
============================================
  Files           123      123              
  Lines         65641    65641              
============================================
- Hits          46720    46622      -98     
- Misses        18921    19019      +98     

see 8 files with indirect coverage changes

zuiderkwast added a commit that referenced this pull request Mar 18, 2025
The unit test was added in #1741. It fails when compiled with UBSAN.
Using a local array like `char buf[size]` is undefined behaviour when
`size == 0`. This fix just makes it size 1 in this case.

The failure I got locally:

unit/test_bitops.c:28:13: runtime error: variable length array bound
evaluates to non-positive value 0

Signed-off-by: Viktor Söderqvist <[email protected]>
xbasel pushed a commit to xbasel/valkey that referenced this pull request Mar 27, 2025
The unit test was added in valkey-io#1741. It fails when compiled with UBSAN.
Using a local array like `char buf[size]` is undefined behaviour when
`size == 0`. This fix just makes it size 1 in this case.

The failure I got locally:

unit/test_bitops.c:28:13: runtime error: variable length array bound
evaluates to non-positive value 0

Signed-off-by: Viktor Söderqvist <[email protected]>
xbasel pushed a commit to xbasel/valkey that referenced this pull request Mar 27, 2025
The unit test was added in valkey-io#1741. It fails when compiled with UBSAN.
Using a local array like `char buf[size]` is undefined behaviour when
`size == 0`. This fix just makes it size 1 in this case.

The failure I got locally:

unit/test_bitops.c:28:13: runtime error: variable length array bound
evaluates to non-positive value 0

Signed-off-by: Viktor Söderqvist <[email protected]>
murphyjacob4 pushed a commit to enjoy-binbin/valkey that referenced this pull request Apr 13, 2025
The unit test was added in valkey-io#1741. It fails when compiled with UBSAN.
Using a local array like `char buf[size]` is undefined behaviour when
`size == 0`. This fix just makes it size 1 in this case.

The failure I got locally:

unit/test_bitops.c:28:13: runtime error: variable length array bound
evaluates to non-positive value 0

Signed-off-by: Viktor Söderqvist <[email protected]>
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.

3 participants