Repository navigation
Never build the symbol index for the bare fatal stack trace - #120148
Conversation
The `Stack trace:` line in the fatal signal handler is the raw fallback that has to come out even when symbolization later fails, but `writeResolvedAddress` routed it through `StackTrace::resolveAddress`, which calls `SymbolIndex::instance` and so builds the index on demand. `instance` is a function-local static: a fault in the thread that was building it would leave the signal listener blocked on the static's guard before the first dump, and a fault during startup would print nothing until ~25 MiB of ELF parsing had been done inside the handler. Add `SymbolIndex::instanceIfInitialized`, which hands out the index only after the constructor has published it through an atomic pointer and never touches the guard, and `StackTrace::tryResolveAddress` on top of it. The bare dump uses that and falls back to the raw runtime address when the index is not built yet. A daemon builds the index during initialization for its build id, so the server still prints the ASLR-independent offsets that `test_crash_log` checks. Addresses #119284 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [4a4fb9f] Summary: ✅
AI ReviewSummaryThis PR makes the fatal-signal pre-dump path stop lazily building Final Verdict
LLVM Coverage ReportMeasured on commit 4a4fb9f.
Changed lines: Changed C/C++ lines covered: 38/39 (97.44%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units94 translation units recompiled, 474 s compile time in total, 94 of them have a recent master baseline. |
…_id` either The bare dump of addresses is only useful if everything printed before it can come out too. In `clickhouse-client` and `clickhouse-local` the short fault info logged by `SignalListener::onFault` asks for the build id, and that lambda called `SymbolIndex::instance`, so a fault at startup, or in the thread that was building the index, blocked the fatal handler on the function-local static's guard before the first `Stack trace:` line was written. Use `SymbolIndex::instanceIfInitialized` for that line: the build id is printed when it is already known and reported as `<not yet known>` otherwise. The full fault info, which comes after the bare dump, still prints the real build id, and for a daemon nothing changes because it has the build id as a plain string. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-symbol-index-build
The negative half of `gtest_symbol_index_if_initialized` only ran when no earlier test in `unit_tests_dbms` had already built the process-global symbol index, so CI could pass without ever exercising the state this change is about. It now runs as a `threadsafe` death test: gtest re-executes the test binary for the child, so the child runs this test alone and `instanceIfInitialized` is guaranteed to be asked before anything else could have built the index. Control: with `--gtest_repeat=3` the parent has a built index from iteration 1 onwards, and the death test still passes, which proves the child is a fresh process rather than a fork inheriting the built index. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`StackTrace::tryResolveAddress` returns `std::nullopt` only on the `__ELF__ && !defined(OS_FREEBSD)` path; on Darwin and FreeBSD it returns an engaged `ResolvedAddress` with `AddressKind::Unsupported` regardless of whether `SymbolIndex` has been built, so the death test would have failed there. Guard that expectation with the same condition and assert the `Unsupported` answer on the other platforms; the part that matters everywhere - asking never builds the index - is still checked unconditionally. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-symbol-index-build
|
🕵 @groeneai, the only red here is It is unrelated to this PR, which touches only The fix is already in progress: #121163 (with #121144 as the alternative revert route). Nothing to do on this PR - it will go green once one of those lands on |
|
🕵 A second red appeared after my previous comment: This is the fleet-wide infrastructure failure tracked in #120462, with fixes in flight: #121048 and #118708. So both reds on this PR - |
|
Confirmed on both, with what changed since your comments:
|
|
🕵 Thanks @groeneai - that matches what I see on head
State of the PR right now: branch is not behind |
…-symbol-index-build
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120148&sha=72259a6b5358ca777f96a48063edf15816c02b2d&name_0=PR&name_1=BuzzHouse%20%28amd_msan%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The only red on this PR is now It is unrelated to this PR, which only touches
It appeared on 2026-09-20 and hits 8-9 distinct pull requests per day plus Status of the other two reds reported earlier on this PR: |
|
The fix is already open and is mine: #121134, "Skip The One refinement to the census: those 19 rows are 4 signatures, and 17 of them are this single defect. |
|
🕵 Thanks @groeneai - agreed on the One new red on head It is the same randomized-settings flake you already have a fix for: the runner's diagnosis reproduces it 308/308 with the randomized settings, 0/323 without, and minimizes to State otherwise unchanged: 0 unresolved review threads, AI Review |
…-symbol-index-build
Follow-up to the re-land of PIE and file offsets in the bare fatal stack traces, addressing the review thread left open there: #119284 (comment)
The
Stack trace:line in the fatal signal handler is the raw fallback that has to come out even when symbolization later fails. After the re-land it went throughStackTrace::resolveAddress, which callsSymbolIndex::instanceand builds the index on demand.instanceis a function-local static, so a fault in the thread that was building it would leave the signal listener blocked on the static's guard before the first dump, and a fault during early startup would print nothing until the ELF parsing had been done inside the handler.This adds
SymbolIndex::instanceIfInitialized, which hands out the index only after the constructor has published it through an atomic pointer and never touches the guard, andStackTrace::tryResolveAddresson top of it. The bare dump uses that and falls back to the raw runtime address when the index is not built yet. A daemon builds the index during initialization for its build id, so the server still prints the ASLR-independent offsets thattest_crash_logchecks (verified locally by sendingSIGSEGVto a server built from this branch: theStack trace:offsets match the symbolized lines that follow).Related: #119284
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120148]
Version info
26.10.1.460-master(included in26.10and later)