Skip to content

Do not publish runtime addresses in system tables - #126760

Merged
Algunenano merged 14 commits into
ClickHouse:masterfrom
Algunenano:hide-raw-addresses-system-tables
Oct 22, 2026
Merged

Algunenano merged 14 commits into
ClickHouse:masterfrom
Algunenano:hide-raw-addresses-system-tables

Conversation

@Algunenano

@Algunenano Algunenano commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

system.trace_log, system.stack_trace, system.errors, system.error_log, system.crash_log and system.processors_profile_log no longer contain runtime memory addresses. This matters only for builds with PIE, which today means Linux.

  • Stack frames inside the main binary are stored as offsets, as before, and other frames (shared libraries, JIT code) as 0, keeping their position. StackTrace::resolveAddressForStorage does this for every trace column, including trace_log rows from the query profiler and from XRay instrumentation.
  • trace_log.symbols and trace_log.lines are still resolved from the runtime addresses, so frames in libc keep their names.
  • trace_log.ptr is a keyed hash, so an allocation and its deallocation still match (e.g. in flameGraph(trace, size, ptr)), but the heap address is not published.
  • flameGraph skips a 0 frame instead of ending the trace there.
  • processors_profile_log id, parent_ids and plan_step are indices within the query instead of heap addresses of processors and plan steps.
  • The stack trace that MemoryLargeAllocation writes to the server log is formatted by StackTrace, like any other stack trace.
  • The TOO_DEEP_RECURSION message no longer prints the stack and frame addresses.
  • BackgroundSchedulePool no longer uses the address of a function pointer as the task type id, which it logs.

Related: #126039

Changelog category (leave one):

  • Improvement

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

System tables no longer contain runtime memory addresses: stack frames outside the main binary are stored as 0, system.trace_log.ptr is an identifier instead of an address, and the ids in system.processors_profile_log are indices within the query.


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

Version info

  • Merged into: 26.11.1.572-master (included in 26.11 and later)
  • Backported to: 26.10.2.82

Frames outside the main binary are stored as 0 in all trace columns, `trace_log.ptr` is a keyed hash, `processors_profile_log` ids are per-query indices, and `TOO_DEEP_RECURSION` no longer prints stack addresses.

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

clickhouse-gh Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b747f5e]

Summary: ✅


AI Review

Summary

The PR replaces runtime addresses with executable offsets, hidden frames, keyed allocation identifiers, and per-query processor identifiers. The four earlier findings are addressed, but the address-hiding contract remains incomplete for jemalloc-backed system tables.

Findings

❌ Blockers

  • src/Common/StackTrace.h:156: Jemalloc profiling tables still publish runtime addresses. JemallocSampledAllocationsSource::generate copies raw program counters into system.jemalloc_sampled_allocations.trace. JemallocProfileSource::generateRaw returns the original profile, while generateSymbolized prints raw counters and appends the original profile. With live sampled allocations, these SQL outputs still disclose the process address layout on Linux. Normalize the numeric trace and sanitize addresses and mapping ranges in both text modes, retaining original addresses only internally for symbolization. The SYSTEM JEMALLOC privilege does not make the published addresses safe.
Tests
  • ⚠️ Add a focused regression with a live jemalloc-profiled allocation that verifies address hiding in system.jemalloc_sampled_allocations.trace and the raw and symbolized modes of system.jemalloc_profile_text.
Final Verdict

Status: ❌ Block. Extend address hiding to the jemalloc-backed table outputs and cover those paths with regression tests.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 19, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-logging Logging/monitoring/observability (logs, metrics, tracing, instrumentation). label Oct 19, 2026
Algunenano and others added 3 commits October 19, 2026 18:19
Frames outside the main binary are now stored as 0 in `system.errors`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Processors/IProcessor.cpp Resolved
Algunenano and others added 2 commits October 20, 2026 14:16
A cloned step is a separate node in `system.processors_profile_log`. The test no longer `ARRAY JOIN`s `trace` with `symbols`, which can have different sizes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Common/StackTrace.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit b747f5e3c844c304a43d54ed810780a43087d288 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

@alexey-milovidov

Copy link
Copy Markdown
Member

trace_log.ptr is a keyed hash

Why not offsets from the object? (I thought we already store them linke this so addr2line work, but we don't expose the ASLR offset)

@Algunenano

Copy link
Copy Markdown
Member Author

Why not offsets from the object? (I thought we already store them linke this so addr2line work, but we don't expose the ASLR offset)

It also contains heap addresses, usually pointers to an allocation. Since we only care about matching allocation and free of the same pointer, using a hash seemed like the simplest solution.

`ErrorLog` now queues runtime addresses and converts them only for the `last_error_trace` column, so frames outside the main binary keep their symbols. Document that raw addresses must never be output. Disable `05408` under MSan and in the flaky check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Interpreters/TraceLog.cpp Resolved
Algunenano and others added 4 commits October 22, 2026 00:28
Each `system.stack_trace` snapshot signals every thread it reads, one at a
time across all queries, so with many copies of the test in parallel
(flaky check under MSan) a single query took over 180 seconds. Reading the
`AsyncMetrics` and `ConfigReloader` threads still gives both main binary
frames and frames outside it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`thread_local_rng` is seeded from the monotonic clock, the thread id and
`uname`, so the key that hides heap addresses could be reconstructed.
`std::random_device` reads the OS randomness source and throws if it
cannot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The style check forbids `std::random_device`. `getentropy` reads the OS
randomness source as well (`getrandom` on Linux, through the glibc
compatibility layer) and the error is thrown instead of falling back to a
predictable key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`clang-tidy` reports `cppcoreguidelines-pro-type-member-init` for the
uninitialized `std::array`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-system-table system.* tables (introspection, system metadata, performance visibility). and removed comp-logging Logging/monitoring/observability (logs, metrics, tracing, instrumentation). labels Oct 21, 2026
Algunenano and others added 2 commits October 22, 2026 10:35
The ppc64le sysroot has an old glibc without `sys/random.h` and `getentropy`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Common/StackTrace.h Resolved
@Algunenano
Algunenano added this pull request to the merge queue Oct 22, 2026
Merged via the queue into ClickHouse:master with commit fc2340a Oct 22, 2026
179 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 22, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 22, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 22, 2026
Backport #126760 to 26.10: Do not publish runtime addresses in system tables
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-system-table system.* tables (introspection, system metadata, performance visibility). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements 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 v26.9-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants