Fix[Options]: correct handling of packed options - #82
Open
678098 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
678098
commented
Jul 24, 2026
| bbis.skip(totalSize - OptionHeader.HEADER_SIZE); | ||
| break; | ||
| } | ||
| size -= header.words() * Protocol.WORD_SIZE; |
Collaborator
Author
There was a problem hiding this comment.
This size decrement was fully wrong for packed options header.
678098
commented
Jul 24, 2026
| : header.words() * Protocol.WORD_SIZE | ||
| - OptionHeader.HEADER_SIZE; | ||
|
|
||
| bbis.skip(numSkip); |
Collaborator
Author
There was a problem hiding this comment.
numSkip is equivalent to totalSize - OptionHeader.HEADER_SIZE (in this PR).
I wanted to have exactly 1 expression so I refactored it to use totalSize.
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.
Problem
When parsing options, the loop decremented the remaining size by
header.words() * WORD_SIZE. For a packedSUB_QUEUE_INFOSoption,words()is reinterpreted as the RDA counter - not a length — while the option occupies exactly one word (the header) on the wire. If another option followed a packed one, size was over-decremented, the loop exited early, and the trailing option bytes were misread as payload -> CRC/parse failure and a dropped message. Latent in the common non-fanout case where the packed option is the only one.Fix
Compute the option's actual on-wire size once (totalSize, packed-aware) and use it consistently for the size decrement and all skip paths, so byte accounting can never desync regardless of the packed flag.
Test
Added
OptionsTest.testStreamInPackedInfosThenIds: a packedSUB_QUEUE_INFOSoption followed by aSUB_QUEUE_IDS_OLDoption. Fails on the old code (trailing option dropped, stream left non-empty); passes with the fix.