Repository navigation
Collect leaked ASan fake frames at the top of the FunctionsStress worker loop - #126210
Conversation
…ker loop With detect_stack_use_after_return (on by default), every instrumented frame with an address-taken local lives on a per-thread fake stack. A frame unwound by an exception is not released: __asan_handle_no_return only sets needs_gc_, and the next fake-frame allocation frees only the slots whose real_stack lies below its own. The stress workers throw on most of their ~15M overload resolution attempts per run, and the first allocation after the catch usually comes from a frame deeper than the leaked ones, so the leaked frames survive. Size classes 3 and 4 fill up on every worker within a minute, and class 1 fills with IFunctionOverloadResolver::getReturnType frames since ClickHouse#125488 moved that frame from class 2 to class 1. A full class makes every allocation from it scan all 8192 slot flags. IColumn::compareAt calls assertTypeEquality, which takes a class-1 frame, once per element, so the per-row determinism checks of range() over a few hundred thousand elements take minutes and the watchdog reports the thread as stuck. Calling __asan_handle_no_return and then allocating a fake frame from a small helper at the top of every iteration runs FakeStack::GC from just below run(), above every frame a previous iteration created, so all leaked slots are freed. The helper's real frame is smaller than those of the loop's callees, so their leaked frames lie below the GC point. Leaked frames are dead and GC poisons them, so use-after-return detection is unchanged. Other builds compile an empty function. Co-Authored-By: Claude Opus 5.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 review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261016-050000 |
|
Workflow [PR], commit [df38bde] Summary: ❌
AI ReviewSummaryAdds an ASan-only cleanup hook between Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; routine CI validation remains pending. |
|
cc @Algunenano, could you review this and add |
CI finish ledger - df38bdeEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261016-100008 |
9613f95
|
26.10 contains #125488 but not this fix, so the stuck |
Backport #126210 to 26.10: Collect leaked ASan fake frames at the top of the FunctionsStress worker loop
… of the FunctionsStress worker loop
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
FunctionsStress.stressfrees the ASan fake-stack frames that exceptions leave behind in its worker threads, sorangeiterations no longer stall in the ASan build.Description
Unit tests (asan_ubsan, function_prop_fuzzer)failed with1 threads got stuckonrange(...)in 9 runs on 2026-10-15, for example master 8f4f38d7. Every failure was in a build compiled with-fPIE(#125488): 0 of 343-fPICruns vs 23 of 388-fPIEruns with a stuck thread or arangeiteration over 12 s.With
detect_stack_use_after_return, frames unwound by an exception stay on the thread's fake stack. They are freed only by the first fake-frame allocation after the throw, and only if they are below it, but that allocation is libcxxabi'sscan_eh_tabsearching for the handler, below the throw site. The workers throw on most of their ~15M overload attempts per run, so size classes fill up. A full class makes each allocation from it scan all of its slots (8192 in class 1). Since #125488,IFunctionOverloadResolver::getReturnTypeleaks into the class thatIColumn::assertTypeEqualitytakes on everycompareAt, sorange's per-element result checks stall.At the top of every iteration the worker now calls
__asan_handle_no_returnand allocates one fake frame from a small helper, which frees every frame left by earlier iterations. Other builds get an empty function.Validation on an ASan build of master, 600-s runs, CI options: without the change, size classes 1, 3 and 4 fill up in 8 of 8 runs, and one run of 9 reproduced the failure (
Thread is stuck for 344.0s ... range(CAST(1192683 AS UInt32)), stuck in__asan_stack_malloc_1underassertTypeEquality). With the change, no class holds more than 97 slots and 24 runs had 0 stuck threads. Overload attempts went up 24%, and the fake-stack share of CPU dropped from 32% to 14%. CI has had no such failure in 199 runs since 20:30 UTC on 2026-10-15, but passing runs still log 13-88 srangeiterations.Related: #125488
Related: #126137
Workflow [PR]
Sync PR [sync-upstream/pr/126210]
Version info
26.11.1.304-master(included in26.11and later)26.10.3.8