Skip to content

Validate values of deserialized gini states - #130488

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-gini-deserialize-validation
Nov 11, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-gini-deserialize-validation

Conversation

@Algunenano

@Algunenano Algunenano commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

gini checked values for being negative, infinite or NaN only in add, not when loading a serialized state. A crafted state with negative or infinite values got past these checks and caused signed integer overflow when computing the result, which is undefined behavior. One shared check now covers both paths.

Related: #114643

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Aggregate function gini now validates values when reading a serialized state, rejecting negative and infinite values (and NaN) the same way as ordinary input.


Workflow [PR]
Sync PR [sync-upstream/pr/130488]

Version info

  • Merged into: 26.11.1.1962-master (included in 26.11 and later)

`deserialize` skipped the checks done by `add`, so a crafted state with negative or
infinite values reached signed integer overflow in `getResult`. Share one validator
between both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [37a63c5]

Summary: ✅


AI Review

Summary

The PR validates deserialized gini states, rejecting negative, infinite, and NaN values before finalization. No actionable findings at commit 37a63c52f8815c645fc54db6dbe44f2e86db06ba. The new regression test and existing aggregate test both pass in Fast test CI; tests were not run locally.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). labels Nov 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 37a63c52f with master 80a80f8e1 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.94, programs/clickhouse-keeper ×1.18 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 7.7 s 18.9 s +11.6 s (+160%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.9 s 8.8 s +5.1 s (+139%)
Compile time of recompiled translation units

7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline.

Job report

@Algunenano
Algunenano added this pull request to the merge queue Nov 11, 2026
Merged via the queue into ClickHouse:master with commit 687344e Nov 11, 2026
194 checks passed
@Algunenano
Algunenano deleted the fix-gini-deserialize-validation branch November 11, 2026 14:28
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 11, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 11, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 11, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 11, 2026
Backport #130488 to 26.8: Validate values of deserialized `gini` states
clickhouse-gh Bot added a commit that referenced this pull request Nov 11, 2026
Backport #130488 to 26.10: Validate values of deserialized `gini` states
clickhouse-gh Bot added a commit that referenced this pull request Nov 11, 2026
Backport #130488 to 26.9: Validate values of deserialized `gini` states
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants