Repository navigation
Conversation
…at 48 REQ - The number of sections of a compactor stops doubling at 48 (MAX_NUM_SECTIONS), as in C++. Doubling past it needs a state of 2^47, reachable only from a crafted image, and overflowed the byte that holds the number of sections, so the sketch could not be read back. - heapify rejects a compactor with more than 48 sections. - heapify rejects an estimation-mode image whose N is not the total weight of its retained items. KLL - Validation of full compact and updatable images rejects an n that is negative or less than the number of retained items. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Java counterparts of checks added in ds-cpp #587. Independent of #808 and #809 (no conflicts).
REQ
The section count could overflow. The number of sections in a compactor starts at 3 and doubles when the compactor's state reaches 2^(numSections − 1). Going from 48 to 96 needs a state of 2^47, which only a crafted image provides. In Java the section count is a
byte, so doubling 96 wraps it to −64, and the compactor is then unusable and can't be serialized and read back.ensureEnoughSections()now stops atMAX_NUM_SECTIONS= 48. C++ Mostly spelling errors and documentation corrections. #587 also stops at 48. Real sketches never reach 96, so normal results don't change.heapifyrejects a compactor with more than 48 sections. Before, up to 127 were accepted as long as sectionSize × numSections ≤ k².N wasn't checked. In an estimation-mode image, N is now checked against the total weight of the retained items, where each item at level h weighs 2^h. Compaction keeps that total equal to N, so any difference means the image is corrupt. The check guards against overflow when it adds up the weights.
KLL
For full compact and updatable images,
KllMemorySegmentValidatenow rejects an n that is negative, or less than the number of retained items, since each retained item weighs at least one. This covers both heapify and wrap, for all four types. Empty and single-item images don't store n.Testing
ReqCorruptImageTest:checkTooManySections: 49 sections are rejected and 48 are accepted.checkSectionDoublingStopsAtMax: a compactor with state 2^50 and 48 sections stays at 48 after a merge.checkNNotEqualToWeight: N + 1, a negative N andLong.MAX_VALUEare all rejected, without large allocations.KllCorruptNTest: for doubles, floats, longs and items, with heapify and wrap, and both compact and updatable images:Long.MIN_VALUEare rejected.All three tests fail on main.
javac -Xlint:all -Xdoclint:all,-missingreports nothing in the changed files.🤖 Generated with Claude Code