Repository navigation
Make sanitizer allocators return null on oversized allocations instead of aborting - #108838
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260629-175500 |
|
cc @azat @Algunenano — could you review this? It sets |
|
Workflow [PR], commit [0dbc4bb] Summary: ✅
AI ReviewSummaryThis PR makes sanitizer builds return Findings
Final VerdictChanges requested: the sanitizer-default change looks fine, but the |
CI finish ledger — 9fa6b4cEvery failure below has an owner. Only
Session id: cron:our-pr-ci-monitor:20260629-233000 |
azat
left a comment
There was a problem hiding this comment.
But the report link is wrong, and let's also add a simple SQL test, it may use "SYSTEM ALLOCATE MEMORY" but should be marked as no-stress since stress tests can be killed in the middle
|
Also here is a better fix - llvm/llvm-project#206649 Add a note in the comment that once we will have this patch we may not need this option |
|
@azat addressed:
|
|
@azat dropped |
d151607 to
5f55f83
Compare
5f55f83 to
70316d8
Compare
70316d8 to
a74e6d1
Compare
CI finish ledger — a74e6d1CI finished (Finish Workflow + Mergeable Check complete; only the private
No PR-caused failures. Approved by @azat. Session id: cron:our-pr-ci-monitor:20260630-190000 |
a74e6d1 to
e83e60d
Compare
Head branch was pushed to by a user without write access
e83e60d to
2586502
Compare
|
The |
CI finish ledger — 2586502Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
Note: the Session id: cron:our-pr-ci-monitor:20260703-210000 |
2586502 to
a38e00e
Compare
| setupUsers(); | ||
|
|
||
| /// SYSTEM ALLOCATE MEMORY is a diagnostic command, harmless to enable in clickhouse-local. | ||
| global_context->allowSystemAllocateMemory(true); |
There was a problem hiding this comment.
clickhouse-local still creates the passwordless default user from setupUsers() and, when no explicit grants are configured, UsersConfigParser grants that user AccessType::ALL except ACCESS_MANAGEMENT. Turning allowSystemAllocateMemory(true) on unconditionally therefore makes SYSTEM ALLOCATE MEMORY reachable in every clickhouse-local session, including ones that later expose listeners via SYSTEM START LISTEN.
That is a bigger behavior change than the test needs: SystemAllocatedMemoryHolder::alloc uses CurrentMemoryTracker::allocNoThrow plus __real_malloc, so it can pin process memory outside the normal query memory-limit enforcement until SYSTEM FREE MEMORY or process exit. Before this patch the same query failed with SYSTEM ALLOCATE MEMORY is not enabled; after it, any connected client with the default local privileges can use it. I think this should stay opt-in for clickhouse-local and be enabled only for the regression test via an explicit flag or config knob.
…d of aborting Set allocator_may_return_null=1 in the default sanitizer options so a single oversized allocation returns null (a recoverable CANNOT_ALLOCATE_MEMORY / std::bad_alloc) instead of the sanitizer runtime calling NORETURN ReportAllocationSizeTooBig and aborting the server. aarch64 MSan caps a single allocation at 8 GiB, below our configured max_allocation_size_mb=32768, so only arm_msan hit the abort as "Server died". The flag governs only the OOM/oversized paths and does not weaken use-of-uninitialized / data-race / UB detection. Once llvm/llvm-project#206649 lands in our toolchain this option may be removable. Enable SYSTEM ALLOCATE MEMORY by default in clickhouse-local (a harmless diagnostic command) so the regression test uses clickhouse-local rather than a standalone server. The test issues an oversized SYSTEM ALLOCATE MEMORY, asserts a following SELECT still runs, and captures the recovery in the reference. ASan and MSan print a benign "<Sanitizer> failed to allocate <N> bytes" warning while TSan and non-sanitizer builds recover silently, so the test routes the sanitizer log to its own file (keeping it out of the runner fatal log) and normalizes the warning to its build-invariant substring with grep -o, falling back to the same token on silent builds, so one reference matches every build. clickhouse-test is left unchanged, so nothing is globally ignored. Co-Authored-By: Claude Opus 4.8 <[email protected]>
a38e00e to
0dbc4bb
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 3/4 (75.00%) · Uncovered code |
…may-return-null Make sanitizer allocators return null on oversized allocations instead of aborting
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Set
allocator_may_return_null=1in the default sanitizer options. A single oversized allocation now returns null (recoverableCANNOT_ALLOCATE_MEMORY) instead of the runtime aborting viaReportAllocationSizeTooBig. aarch64 MSan caps one allocation at 8 GiB, below ourmax_allocation_size_mb=32768, so only arm_msan hit the abort asServer died. The flag governs only OOM/oversized paths; it does not weaken sanitizer detection. Removable once llvm/llvm-project#206649 lands in our toolchain.Report (master,
Stress test (experimental, serverfuzz, arm_msan)): https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=81a8bcef7e8ba2dae3dfdc762dde87a853f40070&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20arm_msan%29The runtime prints a benign
<Sanitizer> failed to allocate ... byteswarning, added to clickhouse-testIGNORED_SANITIZER_ERRORS.SYSTEM ALLOCATE MEMORYis enabled in clickhouse-local so test04417_sanitizer_allocator_oversized_alloc_no_abortcan use clickhouse-local: it issues an oversizedSYSTEM ALLOCATE MEMORY, then asserts aSELECTstill runs.Version info
26.7.1.653(included in26.7and later)