Repository navigation
Fix server abort on a corrupt ORC stripe footer - #114924
Conversation
Reading a corrupt ORC blob aborted debug and sanitizer builds instead of raising INCORRECT_DATA: Check failed: VerifyHasBitConsistency(msg, table) is OK (INTERNAL: Has bits mismatch for Type=orc.proto.StripeFooter Field=1 ORC's DecompressionStream throws where protobuf's ZeroCopyInputStream contract requires a false return, so the exception unwinds through the parser and skips its has-bits write-back. The message is left with a repeated field appended to and its has-bit clear, and since the protobuf v35.1 bump the generated destructor checks that invariant, so destroying the message aborts. Release builds already reported the error correctly because the assertion is compiled out there. The submodule bump makes ORC's protobuf parse boundary honour the stream contract: exceptions are captured, the parser is allowed to finish and leave the message consistent, and the original error is rethrown afterwards. The reported message and error code are unchanged. Reachable from any user-supplied ORC bytes: format(), file(), s3(), url(), and ORC-backed Iceberg or DeltaLake.
ORC's DecompressionStream throws where protobuf's ZeroCopyInputStream::Next contract requires returning false, so the exception unwinds through TcParser and skips its has-bits write-back. StripeFooter is left with the repeated field "streams" appended to and its has-bit clear, and since the protobuf v35.1 bump the generated destructor verifies that invariant, so tearing the message down aborts a debug or sanitizer server instead of raising INCORRECT_DATA. ClickHouse/orc#25 wraps the caller's stream at ORC's parse boundary so exceptions are captured, the contract's failure value is returned, and the original exception is rethrown once the parser has returned consistent. Found by the AST fuzzer (STID 3257-29d9). Related: ClickHouse#114674
Internal second-model review (2 rounds, all findings resolved)Two independent review rounds plus an adversarial second-model gate. Adjudicated: 7 agreed ❌ Gitlink was on a PR-scoped ref only (blocker, raised in both rounds) - the pin was
💡 Carriers enumerated independently before reading the implementer's evidence, and the 💡 Test liveness confirmed, not assumed. The grep alternation also matches 💡 Dropped after measurement (looked like problems, were not): the pin being "diverged" Coverage limit, stated rather than glossed over: the automated gate's change map is a Session id: cron:clickhouse-review-slot-8:20260815-022500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260811-133900 |
|
Workflow [PR], commit [6cb9bb2] Summary: ✅
AI ReviewSummaryThis PR bumps Final Verdict
|
|
cc @tavplubix, could you review this? It is a |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units9 translation units recompiled, 20 s compile time in total, 6 of them have a recent master baseline. Translation units without a recent master baseline:
|
CI finish ledger - 6cb9bb2CI is fully finished on this head with real coverage: praktika reports top-level No failed tests, so there is nothing to own.
One note for the record: CIDB holds a Session id: cron:our-pr-ci-monitor:20260815-093000 |
09de2af
Edited following .claude/skills/edit-changelog/SKILL.md, by hand on a workstation: the editing step of the NightlyChangelog job has been failing its own verification since 2026-08-12, so three raw blocks had accumulated (47 + 84 + 628 entries). Of the 759 raw entries, 482 are integrated into the in-progress 26.8 section and 277 are dropped: - Section 3: the 300 `NOT FOR CHANGELOG / INSIGNIFICANT` entries are dropped, except 41 that describe a user-visible change and are promoted into a real category, among them a server abort on a corrupt `ORC` stripe footer (#114924), `EXPLAIN ANALYZE` for streaming queries (#112445), `SELECT` from `TimeSeries` (#115622), streaming watermarks (#106169), and the `clickhouse-local` CORS overrides (#115129). - Section 2: every revert in the range cancels out inside it, so neither side appears. Two are re-applications: #114912 re-applies the `accurateCastOrDefault` fix, so #109946 keeps its entry with both links and the intervening revert #114911 is gone; #114409 re-applies the PromQL streaming plan, recorded on the #113656 entry. - Section 4: `Build/Testing/Packaging Improvement` keeps the seven entries a user, packager or from-source builder notices (musl `getaddrinfo` and `sched_getcpu`, signed macOS artifacts, Debian packages for release builds only, zstd-compressed Docker layers, `unit_tests_dbms` without the full library set, vendored Rust built with optimizations locally) and drops the CI plumbing. - Sections 5 and 6: bare pull request URLs converted to links, settings put in backticks, four entries rewritten from developer notes into user-visible descriptions, and three moved into `Performance Improvement`. No entry of a strict-retention category was deleted: the job's own `verify_edit` passes on this edit. Not done here, because the release manager does it at release time: the full significance sort, the aggressive merging of sibling pull requests, and the `FIXME` release date and presentation links.
|
This fix is not on the 26.7 and 26.3 release branches. Both still pin 26.7 has just hit the same abort ( 26.3 has the same The cherry-pick should apply cleanly: the submodule bump starts from the branches' current pin, ClickHouse/orc#25 changes only |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Closes: #114674
Related: ClickHouse/orc#25
Reading a corrupt ORC blob aborts a debug or sanitizer server instead of raising
INCORRECT_DATA:Found by the AST fuzzer (
AST fuzzer (amd_debug, targeted),report),
and reproduced on pristine master with default settings by
SELECT c0 FROM format(ORC, 'c0 DateTime64(3)', unhex('4f524311...524317')), so anyuser-supplied ORC bytes reach it.
Root cause. ORC's
DecompressionStreamthrows where protobuf'sZeroCopyInputStream::Nextcontract requires afalsereturn, so the exception originatesinside protobuf's parse loop.
TcParserkeeps has-bits in a register-cached local and writesthem back only on its own exit paths, so the unwind skips that write-back and leaves
StripeFooterwith the repeated fieldstreamsappended to and its has-bit clear. Sincethe v35.1 protobuf bump the generated destructor checks that invariant, so destroying it
aborts.
DebugHardenCheckHasBitConsistency()gates it on!NDEBUGor a sanitizer, sorelease builds are unaffected, hence a CI fix.
Change. A submodule bump only. ORC's parse boundary now wraps the caller's stream in an
adapter that captures anything escaping
Next/BackUp/Skip/ByteCount, returns thecontract's failure value, and rethrows the original exception once the parser has returned
consistent. One header covers all nine
parseProtobufFromStreamcall sites, includingembedder streams such as ClickHouse's
ORCInputStream.Validation. The blob aborts (RC 134) before the change and afterwards reports
Code: 117 ... Read past EOF in DecompressionStream::readBuffer ... (INCORRECT_DATA),byte-identical to master release today, so no user-visible message or code changes. New test
04856_orc_corrupt_stripe_footerpasses 50/50 randomized and fails on the unfixed binarywith the has-bits tokens. A 183-case corruption sweep and the full
orcsuite show nobehaviour change.
ProtobufZeroCopyInputStreamFromReadBuffer(Prometheus remote-write) has the same shape,but is unreported and I could not reproduce a failure there, so it is untouched.