Repository navigation
Conversation
SymbolIndex copied Elf64_Sym::st_value (and + st_size) into Symbol::offset_begin/offset_end without checking that the symbol is defined relative to a section. When st_shndx is a reserved index, the value is a constant rather than an address. -fwhole-program-vtables, enabled for every ThinLTO build, emits LLVM's control-flow-integrity type-id globals (__typeid__*) as absolute symbols whose value is a bit mask. system.symbols published those verbatim, so on amd_release max(address_end) read 1162219258676258 instead of 685204737 (505 such symbols; amd_debug, built with ENABLE_THINLTO=0, has none). An "offset" of 1.16 petabytes into a 4.6 GB binary is impossible on its face. 05076_error_trace_file_offsets bounds captured stack frames by that value, so the raw runtime addresses of frames outside the main executable stopped exceeding it and the test printed "1 0" on every master commit since ClickHouse#117449 merged. The inflated bound also cost the first column its meaning on that flavour, since it counted those same raw addresses as in-range. No test is changed. Once the bound again reflects the largest real symbol offset, both columns of 05076, and the same bound in 03172_error_log_table_not_empty, hold for the reason their comments state. Of the 505 absolute values none lands inside any of the 620643 real FUNC symbol ranges, so no code address resolves differently. The Mach-O collector already skips N_STAB, N_UNDF and n_value == 0; it is left alone because both Darwin recipes disable ThinLTO and no macOS job could validate the change. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding), plus my own cold read of
Independently re-measured rather than taken from the implementation notes: Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20260910-025600 |
|
Workflow [PR], commit [0ff741f] Summary: ❌
AI ReviewSummaryThis PR stops Final Verdict✅ No findings. LLVM Coverage ReportMeasured on commit 0ff741f.
Changed lines: Changed C/C++ lines covered: 15/16 (93.75%) · Uncovered code |
|
cc @al13n321 @alexey-milovidov, could you review this? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 6 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger - f64cbb9CI is fully finished at this commit. One check failed, and it has an owner.
What this PR does fix is green here: Finish evidence: 170 check-runs in the live workflow run 34432949799, 0 queued or in progress, with Session id: cron:our-pr-ci-monitor:20260910-083052 |
`n_value` is an address only for a symbol defined in a section. `N_ABS` holds a constant such as a bit mask and `N_INDR` holds a string table index, so neither belongs in the offset ranges the symbol index is searched by. The loop skipped `N_STAB`, `N_UNDF` and `n_value == 0`; requiring `N_SECT` instead of rejecting `N_UNDF` covers all four non-section types at once and mirrors `symbolValueIsAddress` on the ELF side. Both Darwin recipes disable ThinLTO, so the `__typeid__*` symbols that motivated the ELF change do not exist there and no macOS job can exercise this. It is the same invariant, enforced in the one remaining place that turns a symbol table entry into an offset. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The test asserts that frames inside the main binary reach system.errors.last_error_trace as file offsets, bounded above by max(address_end) from system.symbols. That storage form is ELF-only. StackTrace::resolveAddress is compiled under `#if defined(__ELF__) && !defined(OS_FREEBSD)`. The other arm returns AddressKind::Unsupported with the address unchanged, which StackTrace.h documents as "the platform keeps runtime addresses", so on Darwin resolveAddressForStorage stores a raw runtime address for every frame and none is ever converted to a file offset. collectSymbolsFromMachOImage in turn stores absolute addresses (n_value + slide) and extends each image's last symbol to that image's max_addr, and SymbolIndex::load() runs it for every loaded dyld image. max(address_end) is therefore a ceiling above every captured frame, which makes the second column unsatisfiable and leaves the first no longer measuring the offset form. The test printed `1 0` for that reason, 23 times out of 23 runs. Fast test (arm_darwin) had 23 failures and no passes across 23 distinct pull requests since ClickHouse#117449 added the test, which is every pull request that reached that arm. The assertion is left untouched on the arms whose platform implements the contract it checks. This is a different defect from the one ClickHouse#119136 fixes: unfiltered absolute Mach-O symbols would only raise a ceiling that is already above every frame, so filtering them would leave the output at `1 0`. Related: ClickHouse#119136 Related: ClickHouse#117449 Co-Authored-By: Claude Opus 5 <[email protected]>
|
I'll fix this as part of reintroducing the feature: #119268 |
Related: #117449
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
system.symbolsno longer lists symbols whose value is not an address, such as absolute symbols: theiraddress_begin/address_endwere meaningless. On builds compiled with ThinLTO,-fwhole-program-vtablesemits the control-flow-integrity type-id globals (__typeid__*) as absolute symbols whose value is a bit mask rather than an address, and those were indexed as if they were offsets into the binary, inflatingmax(address_end)by a factor of about 1.7 million.Description
Stateless tests (amd_release, parallel, 1/2)is red on every master commit since #117449 merged, on05076_error_trace_file_offsets, which prints1 0instead of1 1. It reproduces 45/45 with and without randomized settings. Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=baa509a920113525f109868c2448414d963e5252&name_0=MasterCISymbolIndexcopiesElf64_Sym::st_valueintoSymbol::offset_begin/offset_endwithout checking that the symbol is defined relative to a section. Whenst_shndxis a reserved index, the value is a constant rather than an address.-fwhole-program-vtablesis enabled for every ThinLTO build and emits__typeid__*as absolute symbols holding a bit mask, so onamd_releasemax(address_end) FROM system.symbolsreads 1162219258676258 instead of 685204737 (505 such symbols;amd_debughas none). The test bounds captured stack frames by that value, so the raw runtime addresses it looks for stop exceeding it.A section-relative definition is now required in all three places that turn a symbol table entry into an offset: the two ELF collectors, and the Mach-O one, which requires
N_SECTinstead of only rejectingN_UNDF. Each build's bound is again its largest real symbol offset, so05076and03172_error_log_table_not_emptyneed no change.Validated by injecting one
SHN_ABSsymbol into a debug binary: unfixed,05076fails 10/10 with exactly the CI diff; fixed, it passes 10/10.02911_system_symbolsand03565_system_stack_trace_worksalso pass, and05076and03172pass 50 randomized runs each.Stateless tests (amd_release, *)runs only in MasterCI, so this PR's own CI cannot show the failing arm going green; it does so after merge. TheFast test (arm_darwin)red on05076is a separate defect, covered by #119145; that build disables ThinLTO, so__typeid__*cannot exist in it.Workflow [PR]
Sync PR [sync-upstream/pr/119136]