Skip to content

Read ProfileInfo flags as bytes instead of bool - #582

Merged
slabko merged 1 commit into
ClickHouse:masterfrom
iliaal:fix/profileinfo-bool
Oct 28, 2026
Merged

slabko merged 1 commit into
ClickHouse:masterfrom
iliaal:fix/profileinfo-bool

Conversation

@iliaal

@iliaal iliaal commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Client::Impl::ReceiveProfileInfo reads the applied_limit and calculated_rows_before_limit wire bytes directly into bool members. A byte other than 0 or 1 leaves a bool holding an invalid value, and loading it is undefined behaviour. UBSan reports "load of value 5, which is not a valid value for type 'bool'" in OnProfile callbacks, and an optimized build can misbehave.

Fix: read each flag into a uint8_t and store whether it is non-zero. The obsolete has_nested byte in ReceiveException gets the same treatment. No other wire read lands directly in a bool.

Reproducer: a ProfileInfo packet whose applied_limit byte is 0x05.

Test: ClientProtocol.ProfileInfoFlagsAcceptAnyNonZeroByte sends bytes 5 and 255. It fails on master and passes here.

@iliaal
iliaal requested review from mzitnik and slabko as code owners October 18, 2026 16:44
slabko
slabko previously approved these changes Oct 28, 2026
Client::Impl::ReceiveProfileInfo read the applied_limit and
calculated_rows_before_limit wire bytes directly into bool members. A byte
other than 0 or 1 left a bool with an invalid value, and loading it is
undefined behaviour (UBSan reports it in OnProfile callbacks). Read each flag
into a uint8_t and store whether it is non-zero; the obsolete has_nested byte
in ReceiveException gets the same treatment.
@slabko
slabko merged commit c1ddc7a into ClickHouse:master Oct 28, 2026
45 checks passed
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