Repository navigation
Never destroy UntrackedMemoryRegistry - #120386
Algunenano merged 3 commits into
Conversation
A thread owning a `ThreadStatus` can outlive static destruction, and its `UntrackedMemoryCounter` destructor then writes into the already destroyed registry, crashing with a null write in `boost::intrusive`. Every program entry point joins the global thread pool before returning from `main`, but the libFuzzer entry points do not own `main` and cannot, so give the registry a lifetime that covers the whole process instead of relying on that invariant. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=eb77c64f3d9837380c3b793e5688162493efe12c&name_0=NightlyFuzzers&name_1=libFuzzer%20tests&name_1=libFuzzer%20tests Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [bdafb22] Summary: ✅
AI ReviewSummaryThis PR makes Final Verdict✅ No blocking issues found in the current PR head. LLVM Coverage ReportMeasured on commit bdafb22.
Changed lines: Changed C/C++ lines covered: 2/2 (100.00%) · 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 units7 translation units recompiled, 5 s compile time in total, 7 of them have a recent master baseline. |
The destruction order argument belongs in the pull request, not in the source. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
format_fuzzercrashes at process exit, after the fuzzing loop is already done:UntrackedMemoryCounteris a member ofThreadStatusand unregisters itself from the registry when the thread goes away. The registry was a function-local static, so a thread that outlives static destruction writes through an already destroyedboost::intrusivelist head, which is a write to address 0.Every program entry point joins the global thread pool before returning from
main, which is what the old comment relied on. The libFuzzer entry points cannot: libFuzzer ownsmain, and anatexithandler is not a way out either, because the fuzzer's globalContextstill owns the dictionaryPeriodicUpdaterat that point andGlobalThreadPool::shutdown()deadlocks while a background thread is parked on the pool. Giving the registry a lifetime that spans the whole process fixes it for every entry point, present and future, and the object stays reachable through the pointer so it is not reported as a leak. Nothing depends on the registry being destroyed: the only users are theUntrackedMemoryasynchronous metric and theMEMORY_LIMIT_EXCEEDEDmessage, both read-only.Reproduced twice on the CI
format_fuzzerbinary, replaying the 18705-unit corpus (crash at exit, identical stack both times). A standalone reproduction of the same destruction order gives the exact same signature,SEGVatlist_node.hpp:66:16inset_next, and exits cleanly with this change applied.CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=eb77c64f3d9837380c3b793e5688162493efe12c&name_0=NightlyFuzzers&name_1=libFuzzer%20tests&name_1=libFuzzer%20tests
Related: #120385
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/120386]
Version info
26.10.1.359-master(included in26.10and later)