Repository navigation
fix(utils): use a size_t shift operand in ceil_log2 - #247
Merged
Merged
Conversation
`1UL` is 32 bits on LLP64 (64-bit Windows), so ceil_log2 shifted past the operand width for inputs of 2^32 or more. No library code calls it. Reported in #246.
This was referenced Nov 19, 2026
TamimEhsan
pushed a commit
to TamimEhsan/khorgosh
that referenced
this pull request
Nov 28, 2026
The 0.8 to 0.9 section now lists, next to the int64 IDs and index format 2, what only the release notes mentioned: HNSW-routed IVF indexes no longer write a .hnsw sidecar, load raises rabitqlib.FormatError (a RuntimeError and ValueError subclass), the index classes are plain extension classes (pybind11 TypeError, no inspect.signature), and an invalid argument may be reported before a wrong state. The release notes add the ceil_log2 fix from VectorDB-NTU#247.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ceil_log2ininclude/rabitqlib/utils/tools.hppshifted1UL, which is 32 bits on LLP64 (64-bit Windows). For inputs of 2^32 or more the shift count reaches 32, which is undefined. The shift operand is nowsize_t{1}. No library code callsceil_log2, so nothing in the library changes behavior.Reported in #246.
Testing
Local, Linux x86-64, clang, Release, core-only build,
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF:ToolsTest.CeilLog2RoundsUpAcrossSizeTWidthchecks 0, 1, 3, every 2^k and 2^k + 1 across thesize_twidth, andSIZE_MAX.ctest: 156 of 156 passed.uint32_t{1}to mimic the LLP64 width, the new test fails from 2^32 onward (for example 33 instead of 32); it passes again with the fix. On LP64 the old1ULis already 64 bits, so the test cannot fail there for the original code../scripts/check-format.sh,git diff --check.clang++-23 --target=x86_64-pc-windows-msvc -fsyntax-only, a constexpr copy of the old expression failsstatic_assert(ceil_log2(2^32) == 32)withshift count 32 >= width of type 'unsigned long' (32 bits); the new expression passes for 2^32 andSIZE_MAX.