Skip to content

Bounds-check skipping fully filtered values in the Parquet PLAIN string decoder - #131797

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-parquet-plain-string-filtered-page-skip
Nov 17, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-parquet-plain-string-filtered-page-skip

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

When PREWHERE filters out every value of a page, PlainStringDecoder (with a non-trivial converter, e.g. reading Geometry from WKB) skipped the values with its own loop that did not check the lengths against the page size, so a malformed page could make it read out of bounds. Use skip, which checks them.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix a possible out-of-bounds read in the Parquet reader when PREWHERE filters out a whole page of a PLAIN-encoded string column read through a conversion (e.g. to Geometry).

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2535-master (included in 26.11 and later)
  • Backported to: 26.10.5.52, 26.9.31.25, 26.8.39.16, 26.3.66.14

…ring decoder

When `PREWHERE` filters out every value of a page, `PlainStringDecoder` (with a non-trivial converter, e.g. reading `Geometry` from WKB) skipped the values with its own loop that did not check the lengths against the page size, so a malformed page could make it read out of bounds. Use `skip`, which checks them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dc2eb9c]

Summary: ✅


AI Review

Summary

The change bounds-checks skipped PLAIN string values in the Parquet reader when PREWHERE rejects every value in a page, and checks length prefixes before reading them in every PlainStringDecoder loop. Both previous findings are addressed: the decoder checks no longer depend on padding, and the regression test now corrupts a length in a fully filtered page and expects INCORRECT_DATA. No unresolved findings remain at dc2eb9c3505892e23be57bf4be9999d6af1c4966.

The regression passed all 50 runs in targeted ARM ASan/UBSan CI at the fixing commit; the relevant decoder implementation and test are unchanged at the reviewed head. Tests were not run locally because this checkout has no ClickHouse binary or build directory.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing dc2eb9c35 with master d45f558d0 (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.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-parquet-reader-v3 Issues related to the native Parquet reader. label Nov 15, 2026
…ringDecoder`

The decoder loaded the four-byte length prefix before checking the remaining bytes, relying on the
input being padded. A page retained directly from a page-cache cell is not padded, so a malformed page
could still read up to four bytes beyond the allocation. Check that the prefix itself is available in
every loop of `PlainStringDecoder`.

Add a regression case that corrupts a `PLAIN` `BYTE_ARRAY` length in a page whose rows are all
rejected by `PREWHERE` while other rows of the block pass, and expects `INCORRECT_DATA`. Verified
that it fails without the fix.

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

@clickhouse-gh clickhouse-gh Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review approves this commit, see the AI Review comment.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit fc8a493 Nov 17, 2026
193 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-parquet-plain-string-filtered-page-skip branch November 17, 2026 05:02
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 17, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Nov 17, 2026
Cherry pick #131797 to 26.3: Bounds-check skipping fully filtered values in the Parquet `PLAIN` string decoder
robot-clickhouse added a commit that referenced this pull request Nov 17, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 17, 2026
Backport #131797 to 26.10: Bounds-check skipping fully filtered values in the Parquet `PLAIN` string decoder
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 17, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 17, 2026
Backport #131797 to 26.8: Bounds-check skipping fully filtered values in the Parquet `PLAIN` string decoder
PedroTadim added a commit that referenced this pull request Nov 17, 2026
Backport #131797 to 26.3: Bounds-check skipping fully filtered values in the Parquet `PLAIN` string decoder
mkmkme pushed a commit to Altinity/ClickHouse that referenced this pull request Nov 17, 2026
…red values in the Parquet `PLAIN` string decoder
clickhouse-gh Bot added a commit that referenced this pull request Nov 17, 2026
Backport #131797 to 26.9: Bounds-check skipping fully filtered values in the Parquet `PLAIN` string decoder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-parquet-reader-v3 Issues related to the native Parquet reader. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants