Skip to content

Fix[Options]: correct handling of packed options - #82

Open
678098 wants to merge 1 commit into
bloomberg:mainfrom
678098:270724_option_header_compression
Open

Fix[Options]: correct handling of packed options#82
678098 wants to merge 1 commit into
bloomberg:mainfrom
678098:270724_option_header_compression

Conversation

@678098

@678098 678098 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Problem

When parsing options, the loop decremented the remaining size by header.words() * WORD_SIZE. For a packed SUB_QUEUE_INFOS option, 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 packed SUB_QUEUE_INFOS option followed by a SUB_QUEUE_IDS_OLD option. Fails on the old code (trailing option dropped, stream left non-empty); passes with the fix.

Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
bbis.skip(totalSize - OptionHeader.HEADER_SIZE);
break;
}
size -= header.words() * Protocol.WORD_SIZE;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This size decrement was fully wrong for packed options header.

: header.words() * Protocol.WORD_SIZE
- OptionHeader.HEADER_SIZE;

bbis.skip(numSkip);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@678098
678098 requested a review from pniedzielski July 24, 2026 15:54
@678098 678098 changed the title Fix[Options]: correct handling of compressed options Fix[Options]: correct handling of packed options Jul 24, 2026
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.

2 participants