Repository navigation
Print file offsets in the bare fatal stack traces and build the release binary as PIE - #117449
Conversation
`SignalListener::onFault` logs the stack trace twice: a bare list of addresses first, in case symbolization fails, and the symbolized lines after it. The bare list printed raw runtime addresses while the symbolized lines print offsets relative to the object that contains them, so the two were in different address spaces and the one line that survives a symbolization failure was the one that cannot be fed to `addr2line`. Every amd64 and aarch64 build except the three `ENABLE_THINLTO` ones is already a position independent executable, so those runtime addresses depend on wherever ASLR happened to place the image. Route both bare dumps through `StackTrace::resolveAddress`, which returns the representation `StackTrace::forEachFrame` already computes. An offset is only interpretable together with its object, because the offset ranges of the main executable and of the loaded libraries overlap, so a frame outside the main executable is printed as `<offset> in <object>`. A frame that no loaded object contains, which is what JIT code and anything mapped after `SymbolIndex` took its one-time snapshot look like, is printed as `<address> in <unknown>` instead of silently as an offset. Darwin, FreeBSD and non-ELF platforms do not normalize addresses at all, and there the output is unchanged. `StackTrace::forEachFrame` now shares that arithmetic instead of repeating it. The new integration test compares the bare addresses of a fault against the symbolized addresses of the same fault, which needs no reference values, and reproduces the defect on the parent commit. Co-Authored-By: Claude Opus 5 <[email protected]>
`ENABLE_POSITION_INDEPENDENT_BINARY` was set for every amd64 and aarch64 build except the `ENABLE_THINLTO` ones, so `amd_release`, `arm_release` and `amd_cfi` were the only three still linked with `-no-pie`, and therefore the only ones whose text segment is not subject to ASLR. The carve-out was justified by Position independent binaries and libraries are a little bit slower, than position dependent. We consider build with -flto=thin as trully "production" build where each % of performance is important. which is unquantified. The `Performance` job runs `amd_release` and `arm_release` against master head, so it is the instrument that can settle it per architecture. Dropping `-no-pie` alone would not be enough: `ENABLE_POSITION_INDEPENDENT_BINARY` adds compile time `-fPIC` only, so the executable would come out position independent because of the compiler driver default rather than because anything here asks for it, and a differently configured driver would silently ship `ET_EXEC` again. Ask the linker explicitly instead. musl keeps `-static`, which cannot be combined with `-pie` and would need a `-static-pie` `rcrt1.o` that `contrib/musl-cmake` does not build; the FreeBSD and Darwin sysroots carry no `Scrt1.o`; riscv64, ppc64le, loongarch64 and s390x never enter this branch and keep `-no-pie`. Measured locally with the `amd_release` recipe: `-fPIC` together with `-flto=thin` and `-pie` links, the result is `ET_DYN`, and with `remap_executable` enabled the server still remaps 453.70 MiB of its own text into huge pages at startup, so the hugepage remap that `-no-pie` used to protect is not lost. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model reviewI ran an independent review of this branch over five rounds and adjudicated every finding against ❌ Fixed in this PR
💡 Noted, not blocking
Checked and found correct, so not raised The bare dump keeps its "survives a symbolization failure" property: |
Pre-PR validation gate
Verification: a local |
|
Workflow [PR], commit [c161175] Summary: ❌
AI ReviewSummaryThis PR makes Linux glibc PR Metadata
Findings
Tests
Final VerdictNot ready to approve: the main implementation is plausible, but the new CI/test evidence still has two real holes, and the current head still lacks accessible performance-comparison output for the PIE change. LLVM Coverage ReportMeasured on commit c161175.
Changed lines: Changed C/C++ lines covered: 67/75 (89.33%) · Uncovered code |
|
cc @antonio2368 @Algunenano, could you review this? The bare address list that |
| # musl links statically, and -static-pie needs an rcrt1.o that contrib/musl-cmake does not build. | ||
| # The FreeBSD and Darwin sysroots carry no PIC startup objects (Scrt1.o). | ||
| if (OS_LINUX AND NOT USE_MUSL) | ||
| set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -Wl,-pie") |
There was a problem hiding this comment.
This changes the Linux glibc amd64/aarch64 release link mode globally, but the PR currently does not carry the performance evidence the description asks reviewers to read. In PR CI, ci/jobs/scripts/workflow_hooks/filter_job.py:470-479 hard-skips the AMD perf matrix on non-pr-performance PRs, and there are no Performance Comparison results attached to this commit yet. Since the only stated reason the old ENABLE_THINLTO carve-out existed was possible release-build slowdown, we still need actual amd_release/arm_release before/after numbers (or the label that makes those jobs run) before this can be evaluated as safe to merge.
There was a problem hiding this comment.
Half of this is right, and that half was my error in the description.
arm_release is not gated. filter_job.py:470-479 requires "amd" in job_name, and the rule's own
comment reads "skip AMD perf tests for non-performance update (ARM runs by default)". This PR's own
Config Workflow log shows the split directly: the six
Performance Comparison (amd_release, master_head, N/6) jobs are
set to skipped by custom hook [should_skip_job], reason [Skipped, not labeled with 'pr-performance'],
while the six arm_release ones are listed as scheduled. Over the last 7 days CIDB has arm
Performance Comparison on 967 distinct PRs against amd on 170. No results were attached when you
looked because Build (arm_release) was still running, not because the job will not run.
So arm_release before/after numbers against master head arrive here with no label, and only the
AMD half is opt-in.
What you are really pointing at is correct though: the description sent a reviewer to amd_release
results this PR will not produce. I have corrected it to name what actually runs and what the label
would add.
I am not applying the label myself. If the AMD half is wanted before merge, please add
pr-performance.
`read_server_log` returns the whole rotation history, and `test_crash_log` faults the same module-scoped server seven times before this test runs, so the collection-level checks ran over every crash in the log rather than over the one under test. Measured on the preserved log directory of a whole-module run: the assertions saw 8 faults and 20 bare dumps, of which 1 fault and 2 dumps are this test's. Rewriting only this fault's unannotated frames to ` in <unknown>`, stripping only its object annotations, and deleting only its two bare dump lines each left the suite green, while the same rewrite applied to every fault turned it red. Every earlier validation of this test used a single-test invocation, where the history does not exist and the checks are sound. Blocks now carry the fault they belong to and the test selects the last fault recorded, which is its own because the faults of the tests that follow have not happened yet. The count comes from the log rather than from the blocks, so a fault that logs no bare dump at all fails here instead of silently handing the checks the previous fault's trace. Each of the ten faults in a module run independently carries 4 to 5 annotated and 8 to 10 main-executable frames, so the narrower scope keeps margin on every assertion. Co-Authored-By: Claude Opus 5 <[email protected]>
Build profile diff (arm_release)Comparing Binary sizes
|
| Binary | Master | PR | Δ |
|---|---|---|---|
programs/clickhouse-stripped |
709.12 MiB | 736.85 MiB | +27.73 MiB (+3.91%) |
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.
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.
Object file sizes
15503 object files changed (-3.25 MiB total), 0 added.
| Object file | Master | PR | Δ |
|---|---|---|---|
contrib/hive-metastore-cmake/CMakeFiles/_hivemetastore.dir/__/hive-metastore/ThriftHiveMetastore.cp… |
5.81 MiB | 5.68 MiB | -133.43 KiB (-2.24%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_storage_protos.dir/google/storage/v2/sto… |
1.76 MiB | 1.71 MiB | -46.26 KiB (-2.57%) |
contrib/vectorscan-cmake/CMakeFiles/_vectorscan.dir/__/vectorscan/src/rose/rose_build_program.cpp.o |
732.05 KiB | 698.10 KiB | -33.96 KiB (-4.64%) |
contrib/arrow-cmake/CMakeFiles/_parquet.dir/__/arrow/cpp/src/generated/parquet_types.cpp.o |
1017.44 KiB | 986.57 KiB | -30.87 KiB (-3.03%) |
contrib/google-protobuf-cmake/CMakeFiles/_libprotobuf.dir/__/google-protobuf/src/google/protobuf/co… |
365.34 KiB | 336.43 KiB | -28.90 KiB (-7.91%) |
base/poco/Foundation/CMakeFiles/_poco_foundation.dir/src/Exception.cpp.o |
356.32 KiB | 327.53 KiB | -28.79 KiB (-8.08%) |
contrib/libhdfs3-cmake/CMakeFiles/_hdfs3.dir/ClientNamenodeProtocol.pb.cc.o |
1.07 MiB | 1.04 MiB | -24.19 KiB (-2.22%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/messageformat2_data_model.cpp.o |
192.21 KiB | 168.35 KiB | -23.86 KiB (-12.41%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/number_fluent.cpp.o |
124.48 KiB | 103.95 KiB | -20.53 KiB (-16.49%) |
src/CMakeFiles/dbms.dir/Interpreters/ActionsDAG.cpp.o |
1.25 MiB | 1.24 MiB | -20.34 KiB (-1.58%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMAnalysis.dir/__/llvm-project/llvm/lib/Analysis/ScalarEvol… |
1.32 MiB | 1.30 MiB | -18.73 KiB (-1.39%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMCore.dir/__/llvm-project/llvm/lib/IR/ConstantRange.cpp.o |
273.43 KiB | 256.75 KiB | -16.68 KiB (-6.10%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
15852 translation units recompiled, 32793 s compile time in total, 15253 of them have a recent master baseline.
Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +1763.9 s (+6%) in total before that adjustment.
| Translation unit | Master | PR | Δ vs median |
|---|---|---|---|
contrib/grpc-cmake/__/grpc/src/core/xds/grpc/xds_listener_parser.cc |
5.4 s | 11.1 s | +5.3 s (+93%) |
Translation units without a recent master baseline:
contrib/rocksdb-cmake/__/rocksdb/utilities/backup/backup_engine.cc: 7.6 scontrib/s2geometry-cmake/__/s2geometry/src/s2/s2builder.cc: 7.0 scontrib/ai-sdk-cpp-cmake/__/ai-sdk-cpp/src/providers/openai/openai_factory.cpp: 5.9 s
Symbol sizes ⚠️
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse-keeper |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
new | 864.07 KiB | +864.07 KiB |
programs/clickhouse |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
new | 864.07 KiB | +864.07 KiB |
programs/clickhouse-keeper |
wordlist |
new | 242.38 KiB | +242.38 KiB |
programs/clickhouse |
wordlist |
new | 242.38 KiB | +242.38 KiB |
programs/clickhouse |
rd_kafka_properties |
new | 130.00 KiB | +130.00 KiB |
programs/clickhouse |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
new | 102.33 KiB | +102.33 KiB |
programs/clickhouse-keeper |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
new | 102.33 KiB | +102.33 KiB |
programs/clickhouse-keeper |
a_2 |
new | 82.50 KiB | +82.50 KiB |
programs/clickhouse |
a_2 |
new | 82.50 KiB | +82.50 KiB |
Build profile diff (arm_release)Comparing Binary sizes
|
| Binary | Master | PR | Δ |
|---|---|---|---|
programs/clickhouse-stripped |
710.21 MiB | 737.86 MiB | +27.65 MiB (+3.89%) |
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.
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.
Object file sizes
15471 object files changed (-3.24 MiB total), 0 added.
| Object file | Master | PR | Δ |
|---|---|---|---|
contrib/hive-metastore-cmake/CMakeFiles/_hivemetastore.dir/__/hive-metastore/ThriftHiveMetastore.cp… |
5.81 MiB | 5.68 MiB | -133.43 KiB (-2.24%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_storage_protos.dir/google/storage/v2/sto… |
1.76 MiB | 1.71 MiB | -46.26 KiB (-2.57%) |
contrib/vectorscan-cmake/CMakeFiles/_vectorscan.dir/__/vectorscan/src/rose/rose_build_program.cpp.o |
732.05 KiB | 698.10 KiB | -33.96 KiB (-4.64%) |
contrib/arrow-cmake/CMakeFiles/_parquet.dir/__/arrow/cpp/src/generated/parquet_types.cpp.o |
1017.44 KiB | 986.57 KiB | -30.87 KiB (-3.03%) |
contrib/google-protobuf-cmake/CMakeFiles/_libprotobuf.dir/__/google-protobuf/src/google/protobuf/co… |
365.34 KiB | 336.43 KiB | -28.90 KiB (-7.91%) |
base/poco/Foundation/CMakeFiles/_poco_foundation.dir/src/Exception.cpp.o |
356.32 KiB | 327.53 KiB | -28.79 KiB (-8.08%) |
contrib/libhdfs3-cmake/CMakeFiles/_hdfs3.dir/ClientNamenodeProtocol.pb.cc.o |
1.07 MiB | 1.04 MiB | -24.19 KiB (-2.22%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/messageformat2_data_model.cpp.o |
192.21 KiB | 168.35 KiB | -23.86 KiB (-12.41%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/number_fluent.cpp.o |
124.48 KiB | 103.95 KiB | -20.53 KiB (-16.49%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMAnalysis.dir/__/llvm-project/llvm/lib/Analysis/ScalarEvol… |
1.32 MiB | 1.30 MiB | -18.73 KiB (-1.39%) |
src/CMakeFiles/dbms.dir/Interpreters/ActionsDAG.cpp.o |
1.24 MiB | 1.22 MiB | -17.05 KiB (-1.34%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMCore.dir/__/llvm-project/llvm/lib/IR/ConstantRange.cpp.o |
273.43 KiB | 256.75 KiB | -16.68 KiB (-6.10%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units ⚠️
15818 translation units recompiled, 30331 s compile time in total, 4487 of them have a recent master baseline.
Translation units without a recent master baseline:
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_round.cc: 27.9 scontrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp: 23.7 scontrib/llvm-project-cmake/__/llvm-project/llvm/lib/Passes/PassBuilder.cpp: 23.3 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_temporal_binary.cc: 22.5 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc: 20.9 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc: 18.3 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/vector_swizzle.cc: 15.5 scontrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-s3/source/S3Client.cpp: 14.9 scontrib/grpc-cmake/__/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc: 14.5 scontrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp: 14.4 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/vector_sort.cc: 13.9 scontrib/grpc-cmake/__/grpc/src/core/ext/transport/chttp2/transport/http2_server_transport.cc: 13.8 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/scalar_cast_string.cc: 13.7 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/aggregate_basic.cc: 13.6 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/scalar.cc: 13.5 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/vector_select_k.cc: 13.5 scontrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-glue/source/GlueClient.cpp: 13.4 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/hash_aggregate.cc: 13.3 scontrib/arrow-cmake/__/arrow/cpp/src/arrow/builder.cc: 13.2 scontrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-glue/source/GlueClient1.cpp: 12.9 s- ... and 195 more
Symbol sizes ⚠️
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse-keeper |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
new | 864.07 KiB | +864.07 KiB |
programs/clickhouse |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
new | 864.07 KiB | +864.07 KiB |
programs/clickhouse-keeper |
wordlist |
new | 242.38 KiB | +242.38 KiB |
programs/clickhouse |
wordlist |
new | 242.38 KiB | +242.38 KiB |
programs/clickhouse |
rd_kafka_properties |
new | 130.00 KiB | +130.00 KiB |
programs/clickhouse-keeper |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
new | 102.33 KiB | +102.33 KiB |
programs/clickhouse |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
new | 102.33 KiB | +102.33 KiB |
programs/clickhouse |
a_2 |
new | 82.50 KiB | +82.50 KiB |
programs/clickhouse-keeper |
a_2 |
new | 82.50 KiB | +82.50 KiB |
CI finish ledger - 8495b67Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Both owners were checked for a causal link rather than area proximity: #117459 changes exactly Session id: cron:our-pr-ci-monitor:20260901-110000 |
|
@groeneai merge master. |
…ie-bare-trace-offsets
CI finish ledger - a3383a4Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens.
The integration failure also dropped the other 99 jobs of this run ( Session id: cron:our-pr-ci-monitor:20260902-150000 |
|
@groeneai merge master. |
…ie-bare-trace-offsets
|
Merged master at No conflicts, and the PR diff is unchanged (same |
Algunenano
left a comment
There was a problem hiding this comment.
In general the changes look good, but we need a way to verify and confirm that PIE is enabled in all release binaries. I'd suggest doing it in the same check as GLIBC (just reuse and rename it), but I'm open to other options too.
In addition there are a few places that will stop resolving after restart. Here is the analysis:
Inventory of address surfaces under ASLR
┌──────────────────────────────────────────┬────────────────────────────┬───────────────────┬───────────────────────────────────────┐
│ Surface │ Representation │ Survives ASLR │ Symbol string stored alongside │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ Fatal log, bare dump │ object offset + object │ yes │ no, but that is the point of the bare │
│ │ name (after this PR) │ │ dump │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ Fatal log / exception Stack trace: │ physical_addr │ yes │ yes │
│ symbolized │ │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ system.crash_log.trace │ raw runtime addresses │ no │ yes, trace_full is always filled from │
│ │ │ │ toStringEveryLine │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ │ main-object frames │ │ yes by default, symbols and lines │
│ system.trace_log.trace │ normalized in │ partly │ filled unless │
│ │ TraceCollector, library │ │ <trace_log><symbolize>false │
│ │ frames raw │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ system.trace_log Instrumentation (XRay) │ raw runtime addresses │ no │ yes, function_name / function_id │
│ rows │ │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ │ normalized per containing │ │ no column, but it is a live-process │
│ system.stack_trace.trace │ object, object not │ yes │ table │
│ │ recorded │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ system.errors.last_error_trace, │ raw runtime addresses │ no │ no │
│ system.error_log.last_error_trace │ │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ │ file offsets (min=8, │ │ │
│ system.symbols.address_begin/end │ max=698647937 on my PIE │ yes │ n/a │
│ │ build) │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ flameGraph aggregate function │ symbolized in-process, hex │ in-process only │ yes, when the symbol resolves │
│ │ fallback │ │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ Jemalloc symbolized profile source │ symbolizes in-process │ in-process only │ yes │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ Jemalloc raw .heap dumps │ raw runtime addresses │ yes, via │ jeprof handles it │
│ │ │ MAPPED_LIBRARIES │ │
├──────────────────────────────────────────┼────────────────────────────┼───────────────────┼───────────────────────────────────────┤
│ Sentry CrashWriter │ physical_addr + build id │ yes │ yes │
└──────────────────────────────────────────┴────────────────────────────┴───────────────────┴───────────────────────────────────────┘
The two answers to your question
Yes, there is a demangled string stored along with it, on the surfaces that matter. crash_log has trace_full, trace_log has symbols and lines (default symbolize=true), XRay rows have function_name. A human reading a crash after the fact loses nothing. What breaks is arrayMap(x -> addressToLine(x), trace) run against a crash_log row from a different process, and any offline addr2line on those columns.
The one real gap is last_error_trace. It is the only address column that is neither normalized nor accompanied by a symbolized column. Empirically, against my running PIE server:
name: CANNOT_PARSE_TEXT
addr: 55DCBA494673
sym: ['Poco::Exception::Exception(...)', 'DB::Exception::Exception(...)', ...]
addressToSymbol resolves it correctly while the process is alive, because SymbolIndex::findSymbol finds the containing object and converts. Once the row is flushed to system.error_log and the server restarts, or the row is shipped to a central cluster, the address is unresolvable. The column description even claims "physical addresses", which was true only for non-PIE release builds and is now wrong on every build. That is the concrete thing I would ask for: run last_error_trace and crash_log.trace through the new StackTrace::resolveAddress (or at minimum fix the column comment), since the helper this PR adds is exactly what they need. The author disclosed crash_log deliberately, deferring to azat's #101435, which is defensible; error_log is not mentioned at all.
Two smaller notes
system.stack_trace.trace normalizes against whichever object contains the frame but never records which one, so addressToSymbol on a library frame silently returns a main-binary symbol at the same offset. Live on my build right now:
609497 094CD9 __atan_fma
620386 097762 __GI___pthread_cond_timedwait
Those are libm/libpthread offsets landing in a flat symbol table keyed by offset. Pre-existing, identical under non-PIE, not this PR's problem, but it is the same ambiguity the PR's AddressKind enum was invented to solve, so the fix is now one function call away.
The bare dump now depends on SymbolIndex being loaded, which slightly weakens its role as the fallback for when symbolization fails. In practice it is fine: BaseDaemon.cpp:489 loads the singleton at init, and findObject is a lower_bound over an immutable vector with no allocation or locking. Worth a sentence in the PR rather than a change.
The -pie -Wl,-pie pair is redundant (the driver already forwards -pie) but harmless.
Can you extend the PR with both please? @groeneai
…utable -fPIC only makes the code relocatable. Whether the executable itself is position independent is the linker's decision, and nothing in the build fails when it comes out position dependent: the stack traces silently go back to printing runtime addresses. The Compatibility check already unpacks the release deb to read its glibc symbol versions, so the ELF type and DF_1_PIE of that same binary are checked next to them, on both amd64 and aarch64. The type alone is not enough, since a shared library is ET_DYN too, and DF_1_PIE alone would accept a linker that sets the flag without asking for -pie, so both are required. An unreadable or non-ELF file raises instead of passing.
system.errors.last_error_trace, system.error_log.last_error_trace and system.crash_log.trace stored raw runtime addresses. addressToSymbol resolves those while the process that produced them is alive, because SymbolIndex::findSymbol converts an address it finds an object for, but once the row is flushed and the server restarts, or the row is shipped to a central cluster, the address means nothing: the load base differs on every start of a position independent binary. last_error_trace is the worst case of the three, being the only address column with no symbolized column beside it, so nothing else in the row identifies the frames. The column description claiming "physical addresses" was true only for the position dependent release builds this branch removes. Frames in the main executable are now stored as their file offsets, which is what system.trace_log and system.stack_trace already store and what addr2line and llvm-symbolizer take. Frames in other objects keep their runtime address: a bare number column has nowhere to record which object an offset belongs to, and addressToSymbol on a library offset would answer with the main executable's symbol at the same offset, which is worse than not resolving. Fixing that ambiguity for the columns that do normalize per containing object is ClickHouse#101435's subject. The stored value is computed on read rather than at capture, so the exception path does an object lookup per frame only for the rows a query or a log flush actually produces.
The test reads the shared local Code 395 row in `system.errors`. A parallel async-insert test can replace `last_error_trace` with its own fresh error, so the timestamp guard accepts a different query's stack and loses the expected C-library frame. CI captured that overwrite and then passed all 38 isolated diagnostic attempts with the same randomized settings. Use `no-parallel` to run the check in the existing sequential group. Preserve the executable queries and both offset assertions. The official tag parser and classifier verify the changed scheduling; no new server run or assertion change is needed for this metadata correction. Related: ClickHouse#117449 Related: ClickHouse#117830 CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=26e0f6172adfa5219ca56bbb494cc30f5a5529ee&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Codex CLI <[email protected]>
|
@Algunenano, This PR broke master. I will revert. |
…he release binary as PIE" This reverts the changes merged in 30c0912 (pull request ClickHouse#117449). The test it added, `05076_error_trace_file_offsets`, has never passed on two configurations and is red on `master` and on every pull request opened since it merged on 2026-09-09: Fast test (arm_darwin) 0 ok / 130 fail Stateless tests (amd_release, parallel, 1/2) 0 ok / 31 fail Stateless tests (arm_release, parallel) 30 ok / 0 fail every other configuration ~2500 ok / 0 fail Both failing configurations produce the same diff: the second column drops from 1 to 0, so no captured frame lies outside the main executable. The `amd_release` runner reproduced it 48 out of 48 times with the randomized settings and 49 out of 49 without them, so it is deterministic rather than flaky, and `arm_release` passes at the same times, so it is not a scheduling artifact. It merged green because neither failing configuration ran the test on the original pull request - `Fast test (arm_darwin)` and the `amd_release` stateless jobs are absent from its results. The Darwin half was since addressed on `master` by 734d678 (pull request ClickHouse#119145), which tags the test `no-darwin`. That tag cannot help `amd_release`, which is still failing on `master` as of 2026-09-10 15:13 - including on a77884d, the very commit that merged the tag. Reverting removes the test altogether, so that tag goes with it. The feature is worth having; it should return with the test guarded for the configurations whose premise it does not match, and with both jobs above exercised before it merges. Related: ClickHouse#117449 Related: ClickHouse#119145
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 #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]>
Resolves the conflict on 05076_error_trace_file_offsets.sh by taking master's deletion: the test was removed from master by ClickHouse#119279, which reverted ClickHouse#117449. The no-parallel tag this branch added to it goes with the file.
Resolves the conflict on 05076_error_trace_file_offsets.sh by taking master's deletion: the test was removed from master by ClickHouse#119279, which reverted ClickHouse#117449. The no-parallel tag this branch added to it goes with the file.
Edited by hand following .claude/skills/edit-changelog/SKILL.md, consolidating the nine raw blocks generated between 2026-09-06 and 2026-09-13. The NightlyChangelog job rejected its own edits every night in that period: the verifier did not know that #116566 (reverted by #116586) had itself reverted #109710, so it demanded that no trace of #116586 remain while the rules put its link on the CatBoost entry. Fixed in the job by #119866; this edit passes the patched verifier, and the trailers below give the ledger the missing chain. Failed runs: https://github.com/ClickHouse/ClickHouse/actions/runs/34006912773 through https://github.com/ClickHouse/ClickHouse/actions/runs/34668133756 Changelog-revert: 116566 109710 Revert "Remove CatBoost integration" Changelog-revert: 116586 116566 Revert "Revert "Remove CatBoost integration"" Changelog-revert: 117629 117295 Revert "Skip Darwin fast test in PRs unless labeled ci-macos" Changelog-revert: 118525 118218 Revert "Do not wait for the remote drain when cancelling a remote query" Changelog-revert: 119043 117866 Revert "Add `ci-coverage` label to force LLVM coverage jobs on tests-only PRs" Changelog-revert: 119269 118239 Revert "Require agents to run the style check locally before pushing" Changelog-revert: 119270 115343 Revert "Resume a NATS JetStream subscription after a reconnect" Changelog-revert: 119274 118919 Revert "Carry the mutation version onto a rewritten lightweight `DELETE`" Changelog-revert: 119275 114817 Revert "Convert OUTER join to INNER join by null-rejecting join conditions" Changelog-revert: 119276 110939 Revert "Support real hard links for plain_rewritable metadata." Changelog-revert: 119279 117449 Revert "Print file offsets in the bare fatal stack traces and build the release binary as PIE" Changelog-revert: 119281 116629 Revert "Check access rights in the TimeSeries table functions" Changelog-revert: 119298 118606 Revert "Proper partition pruning with dates" Changelog-revert: 119323 117768 Revert "Docs: Skip private sync for documentation-only pull requests" Changelog-revert: 119334 117356 Revert "Unify the spill trigger for hash joins" Changelog-revert: 119429 114562 Revert "Fix NO_SUCH_COLUMN_IN_TABLE naming a column absent from the table when a part's columns were all renamed or all dropped" Changelog-deleted-entry: 110939 [New Feature] [raw] * Disks with the `plain_rewritable` metadata (`s3_plain_rewritable`, and `azure`/`local` object storages with `metadata_type = plain_rewritable`) support hard links if configured with the new `enable_hard_links` setting, which enables `ALTER` operations and mutations on `MergeTree` tables stored on them. Mutations and partition operations share the unchanged blobs between parts instead of copying them. The setting is off by default, because a disk that has hard links cannot be read by older servers. [#110939](#110939) ([yanglongwei](https://github.com/ylw510)). Changelog-deleted-entry: 114562 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed `NO_SUCH_COLUMN_IN_TABLE` naming a column that is not in the table, when reading or merging a part whose columns had all been renamed or all dropped by a mutation that was not applied yet. The merge kept being retried, so the table stopped compacting. Also fixed the columns of a `MergeTree` part produced by such a merge reading as their default values until the mutation was applied. [#114562](#114562) ([Shaohua Wang](https://github.com/tiandiwonder)). Changelog-deleted-entry: 114817 [Performance Improvement] [raw] * Convert `OUTER JOIN` to `INNER JOIN` when a later JOIN condition filters out its NULL-extended rows, and filter NULL join keys directly at the table scan when column statistics show it is selective. Only conditions of the form `expr1` OP `expr2` are considered, where OP is one of `=`, `<`, `<=`, `>`, `>=`. Each side can be a column or an expression that propagates NULLs. Controlled by the new settings `query_plan_derive_not_null_filters_from_joins` (enabled by default), `query_plan_allow_derived_not_null_filters_execution` (enabled by default) and `query_plan_max_selectivity_for_not_null_filters_execution` (0.7 by default). [#114817](#114817) ([Hechem Selmi](https://github.com/m-selmi)). Changelog-deleted-entry: 115343 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed a `NATS` engine table reading from a JetStream stream (`nats_stream`) silently stopping to consume messages after the NATS server restarted or the connection was re-established. [#115343](#115343) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Changelog-deleted-entry: 116629 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * The table functions reading a `TimeSeries` table (`timeSeriesSamples`, `timeSeriesTags`, `timeSeriesMetrics`, `timeSeriesSelector`, `prometheusQuery`, `prometheusQueryRange`) checked no privilege on it: a user holding only `CREATE TEMPORARY TABLE` could read its target tables' column definitions and rows, and write into them. Each now requires the corresponding privilege on the `TimeSeries` table and on the target table, following an `Alias` target through to the table it points at. `timeSeriesSamples`, `timeSeriesTags` and `timeSeriesMetrics` check the target at table level, since they return it whole and cannot restrict the columns, so a column-scoped grant on the target is not enough; the other three run ordinary target queries, which the planner still checks per column. An external target is authorized before it is looked up, so its existence is not disclosed either. A read fails with `ACCESS_DENIED` when the user's effective `SELECT` row-policy filter on the `TimeSeries` table is not always true, since such a policy cannot be enforced on the target's rows, and the three target functions can no longer back a `CREATE TABLE ... AS` (`BAD_ARGUMENTS`). PromQL over the Prometheus HTTP and remote-read endpoints reaches `timeSeriesSelector` whenever it selects series, so those requests now need these privileges for the user the endpoint authenticated. [#116629](#116629) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 117356 [Backward Incompatible Change] [raw] * `max_bytes_before_external_join` and `max_bytes_ratio_before_external_join` are now the spill threshold for every hash-based `join_algorithm`, including `grace_hash`, which previously ignored them and spilled on `max_rows_in_join` / `max_bytes_in_join` instead. Those two are a hard cap again for every algorithm: they no longer cause spilling, and a join that spills no longer exceeds them. All join algorithms remain available; `join_algorithm = 'grace_hash'` now needs a non-zero spill threshold, and is skipped in favour of the next algorithm in the list when it has none. Set `legacy_join_size_limits_trigger_spilling = 1` (or `compatibility` to 26.8 or older) to restore the previous behavior. [#117356](#117356) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). Changelog-deleted-entry: 117449 [Build/Testing/Packaging Improvement] [raw] * ClickHouse is now built as a position independent executable on Linux amd64 and aarch64 with glibc, including the release builds, so the text segment is subject to ASLR. Addresses in the bare stack trace of a fatal log are now file offsets relative to the object that contains them, annotated with that object for frames outside the main executable, so they can be resolved with `addr2line -e <object> <hex>` regardless of where the binary was loaded. For the same reason `system.errors.last_error_trace`, `system.error_log.last_error_trace` and `system.crash_log.trace` now store a frame of the main executable as its file offset, keeping runtime addresses for frames in other objects. [#117449](#117449) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 117768 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Not applicable. [#117768](#117768) ([Dominic Tran](https://github.com/dhtclk)). Changelog-deleted-entry: 118218 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed cancelling a distributed, `s3Cluster` or parallel-replicas `SELECT` taking up to `receive_timeout` (300 s by default) to take effect, and never reaching some of the remote sources, when one of them was draining the packets left over after a `LIMIT` was satisfied. [#118218](#118218) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 118239 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Require agents to run the style check locally before pushing. [#118239](#118239) ([Nikita Fomichev](https://github.com/fm4v)). Changelog-deleted-entry: 118606 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Proper partition pruning with dates. Closes [#103433](#103433). [#118606](#118606) ([Konstantin Vedernikov](https://github.com/scanhex12)). Changelog-deleted-entry: 118919 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed a pending lightweight `DELETE` read with `apply_mutations_on_fly = 1` evaluating its predicate over patch parts created after it, which made rows disappear from the result and reappear after the mutation materialized. [#118919](#118919) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
… build the release binary as PIE"" This reverts 34421af (pull request ClickHouse#119279), restoring pull request ClickHouse#117449. ClickHouse#119279 reverted the change to get `master` green: the test it added, `05076_error_trace_file_offsets`, was failing on every release run. The Darwin half had already been fixed on `master` by 734d678 (pull request ClickHouse#119145), whose `no-darwin` tag comes back with this re-land, but `amd_release` was still failing and remains undiagnosed. Do not merge this before that is fixed - it re-introduces a known red job. What is known about the remaining failure: - Only `Stateless tests (amd_release, parallel, 1/2)` fails. `arm_release` passes at the same times, and so does every other configuration. - It is deterministic, not flaky: 48 of 48 runs with the randomized settings and 49 of 49 without them. - It is the second column that fails, dropping from 1 to 0: no captured frame lies outside the main executable, so either every frame is being stored as a file offset, or `max(address_end)` from `system.symbols` is above all of them. - Both release builds are configured identically apart from the toolchain file, and both set `ENABLE_THINLTO=1`. Before this change PIE was gated on `NOT ENABLE_THINLTO`, so the release builds are exactly the ones whose PIE status it flips - and only the amd64 one fails. The difference is therefore in architecture-specific link or runtime behaviour, not in the CMake configuration. Related: ClickHouse#117449 Related: ClickHouse#119145 Related: ClickHouse#119279
Related: #103347
Reimplementation of #103347 against master; its head is from 2026-06-08.
SignalListener::onFaultlogs the trace twice: a bare address list in case symbolization fails, then the symbolized lines. The bare list printed raw runtime addresses, which ASLR moves, so the line that survives a symbolization failure was the oneaddr2linecannot use. Both bare dumps now print object-relative file offsets, within <object>for a frame outside the main executable, whose offset ranges overlap, andin <unknown>for a frame in no loaded object.The second commit drops the
NOT ENABLE_THINLTOcarve-out, soamd_release,arm_releaseandamd_cfibecome position independent, and asks the linker for-pieexplicitly. It can be dropped alone. ThePerformancejob runsarm_releaseagainst master head and is green here, with oneslowerentry in three of its six batches; theamd_releasebatches are skipped without thepr-performancelabel, so please read it before merging.From @ Algunenano's review:
Compatibility check, which already unpacks the release deb for its glibc symbol versions, now also asserts that binary isET_DYNand carriesDF_1_PIEon amd64 and aarch64, since-fPIConly makes the code relocatable and nothing in the build fails when the executable comes out position dependent. Andsystem.errors.last_error_trace,system.error_log.last_error_traceandsystem.crash_log.tracenow store a frame of the main executable as its file offset, so a flushed row stays resolvable after a restart or on another host, while a frame in another object keeps its runtime address, because a stored offset into a library reads as a main-executable one.Three of the four performance problems no longer exist; the fourth is PIE's own cost, which master's deleted comment called "a little bit slower" without a number. "Always" is only reachable on Linux glibc amd64 and aarch64 today: musl links statically, the other sysroots have no PIC startup objects, and that fix lives on an unmerged
ClickHouse/sysrootbranch I cannot push to.Sysroot gap, validation, and disclosed residuals
contrib/sysrootcaf9c9f560e5a06:linux-powerpc64le,linux-loongarch64,freebsd-x86_64,freebsd-aarch64andfreebsd-powerpc64lehave noScrt1.o(the FreeBSD ones also lackcrtbeginS.o/crtendS.o);linux-riscv64hasScrt1.obut nolibrt.sosymlink, so-lrtfalls back to a non-PIC archive. #103347's sysroot bump points at the unmerged branchpie-ready-linux-sysroots, ahead 2 / behind 3 of sysroot master, one of whose commits is obsoleted by the merged sysroot#45 "Remove musl sysroot". riscv64, ppc64le and loongarch64 keep-no-pie; s390x, musl, FreeBSD and Darwin stay outside the explicit-piepath, and Darwin and FreeBSD trace output is byte-identical. #103347 also stubs outremapExecutablewith#if 0, but6c5298f9b41d8b0made it PIE-safe, so the stub is obsolete: a localamd_releasePIE ThinLTO build still remaps 453.70 MiB of text into huge pages, which is why the compensatingmlock_executableand the perf job's--privilegedare unnecessary.Validation: the
amd_releaserecipe with-fPIC,-flto=thinand-pielinks and yieldsET_DYN;clickhouse localand a server from it both work. The musl configure keeps-fPICbut gets no-pie, the sanitizer configure gets-pie, riscv64 keeps-no-pie. The PIE assertion was run against the real binary and against-pieand-no-pieprobe binaries from bothgccandld.lld: it fails on each-no-pieone and raises on a non-ELF file. The offsets test and the crash-trace assertion fail on the parent commit and pass here; the added stateless test is 50/50 green with randomized settings. The bare dump now depends onSymbolIndexbeing loaded, whichBaseDaemondoes at init, andfindObjectis alower_boundover an immutable vector with no allocation or locking, so the fallback path stays allocation-free.Not fixed here, and disclosed rather than dropped silently:
system.stack_trace.tracenormalizes against whichever object contains the frame without recording which one, so a library frame's offset reads as a main-executable symbol; XRay rows and jemalloc heap-dump addresses are raw;SymbolIndex::findObjectbounds each object by ELF file size rather than loaded extent. @ azat's open #101435 is redesigning that surface, and #115323 is adjacent in the same files. I have not touched either.system.trace_log.traceneeds no change:TraceCollectorsubtracts the main executable's base only, which is the form the error and crash columns now follow.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
ClickHouse is now built as a position independent executable on Linux amd64 and aarch64 with glibc, including the release builds, so the text segment is subject to ASLR. Addresses in the bare stack trace of a fatal log are now file offsets relative to the object that contains them, annotated with that object for frames outside the main executable, so they can be resolved with
addr2line -e <object> <hex>regardless of where the binary was loaded. For the same reasonsystem.errors.last_error_trace,system.error_log.last_error_traceandsystem.crash_log.tracenow store a frame of the main executable as its file offset, keeping runtime addresses for frames in other objects.Workflow [PR]
Sync PR [sync-upstream/pr/117449]
Version info
26.9.1.1087(included in26.9and later)