Repository navigation
Drop lldb's loader rendezvous breakpoint before collecting stacktraces - #114272
alexey-milovidov merged 4 commits into
Conversation
The stress harness reports `Received signal 5` with `_dl_debug_state` in the stack as a fatal signal, and the server dies for it. It is not a fault in server code. `get_stacktraces_from_lldb` attaches lldb under a 30 second ceiling. On attach, DynamicLoaderPOSIXDYLD::DidAttach sets the shared-library-event breakpoint as a software breakpoint, i.e. one 0xcc over the first byte of `_dl_debug_state` in the running server's text. On a 172-thread sanitizer build `thread backtrace all` exceeds the ceiling, and subprocess.run's timeout path is process.kill(): the debugger dies by SIGKILL with no chance to restore the byte. Any later dlopen in that server executes the orphaned int3 and raises SIGTRAP with si_code = SI_KERNEL, which is in fault_signals with only SIGTSTP exempt, so the daemon takes the full fatal path. It is cross-worker, since the eight workers share one server: in the report on ClickHouse#113899, worker 0's collector timed out on server 2885 and 2885 trapped 21 minutes later inside another worker's test. Deleting the breakpoint right after attach removes the cause rather than managing it. From that instant there is nothing for any later kill to orphan: the timeout SIGKILL, stop_tests()'s process-group SIGTERM, a BaseException unwind and an lldb abort() all become harmless at once, with no trigger enumeration and no change to signal handling. An orphaned int3 cannot be fixed at the handler layer anyway, since the original byte is gone and the PC is already past it, so suppressing the report would leave a server that traps forever. A blanket SIGTRAP exemption would also be wrong on aarch64, where __builtin_trap lowers to brk and SIGTRAP's fatal duty is load-bearing. The breakpoint is selected by the symbol its location sits on, not by internal id. Internal ids are assigned in insertion order, and both the JIT hook and the sanitizer runtimes register before the dynamic loader plugin: on a real server id -1 is __jit_debug_register_code, and on a sanitizer build -2 is __ubsan_on_report. Deleting -1 would therefore remove the wrong breakpoint and leave the 0xcc in place on exactly the builds where every occurrence happens. SBBreakpoint does not expose GetBreakpointKind, so the location's symbol name is the available discriminator. The delete runs after DidAttach has built the module map, so symbolization is unaffected; losing shared-library notifications for the rest of the attach is inert, because the inferior stays stopped for the whole backtrace and no library can load in that window. Validated on a real 172-thread server with the harness's exact teardown, on a debug and an ASan+UBSan build, and end-to-end through get_stacktraces_from_lldb: the byte ends 0xcc without the change and stays 0xf3 with it, while the backtrace is unchanged at 3746 frames and 344 threads with the same symbolized count over three paired runs. Should the script command ever fail, --batch continues to the next command and the collector still produces its full dump, so the failure mode is never worse than the current behaviour. CIDB counts 13 occurrences over 180 days across 13 distinct PRs, all sanitizer builds: amd_tsan 7, arm_tsan 3, amd_msan 1, and two stateless amd_tsan. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (2 findings, both disagreed with evidence)An independent model reviewed this diff cold. Both of its findings are recorded here with my ❌ "The collector still runs the backtrace when the breakpoint deletion matches nothing" — ❌ "The test does not prove text restoration after a forced kill, and the release-build server
💡 Noted, not changed: the new test asserts debugger attach succeeded, while the sibling test four |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260811-030500 |
|
cc @leshikus, could you review this? On attach lldb writes an int3 over |
|
Workflow [PR], commit [ee7a654] Summary: ✅ AI ReviewSummaryThe PR teaches Findings
Final VerdictChanges are not ready to merge as-is: the fix still lacks a durable regression guard for the fail-open parser path. LLVM Coverage ReportMeasured on commit ee7a654.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +923 lines in 248 files (-839 lines lost coverage) · Details |
CI finish ledger - f22a713Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Signature confirmed from the Session id: cron:our-pr-ci-monitor:20260812-050000 |
…dezvous-breakpoint Resolves one conflict: ci/tests/test_print_stacktraces.py was deleted on master in 3a69545, which removed the whole ci/tests suite alongside the .claude/CLAUDE.md note that CI script changes are exercised with a throwaway script rather than committed coverage. Six later commits restored 39 of the 71 deleted files by name; this one was not among them, so the deletion is taken. The remaining change is the fix itself in tests/clickhouse-test, unmodified: master's get_stacktraces_from_lldb is byte-identical to the merge-base version, so that half auto-merged, and the added and removed payload lines hash the same before and after the merge.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
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. Compile time of recompiled translation units7 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger — 7abb85dEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260817-183000 |
|
Correction to the My row said the lambda mint "carries no retry, unlike the What actually happened: the mint returned a token, then I am not opening a PR. Nothing in praktika would have saved these jobs: a wider retry budget at that |
…dezvous-breakpoint Resolves one conflict, both hunks inside the lldb collector in tests/clickhouse-test, taking master's side for everything that is not the fix. Master gave get_stacktraces_from_lldb a per-PID budget: LLDB_TIMEOUT and LLDB_SLOW_BUILD_TIMEOUT landed in the same place this branch defines LLDB_DROP_RENDEZVOUS_BREAKPOINT, and the call now passes timeout=timeout where this branch pinned timeout=30. Both constant blocks are kept, master's unchanged, and master's timeout parameter replaces the pinned ceiling, so the fix no longer touches the budget at all. The one line it still changes there is the command string, which gains the breakpoint delete as an extra -o. The merged file differs from master by 15 added and 1 removed line, all of them the fix, and the staged tree differs from master in tests/clickhouse-test alone, so no other master change is disturbed. The collector is still the only lldb --batch call in the file, so the carrier set is unchanged. The merged file parses, and black 26.5.1 reports byte-identical findings on it and on master's own copy, i.e. the resolution adds no formatting divergence. Co-Authored-By: Claude Opus 5 <[email protected]>
The rendezvous-breakpoint drop scanned internal breakpoint ids -1 .. -15 and
filtered by symbol. lldb hands internal ids out of a counter that starts at 0
and decrements, and removing a breakpoint does not return the id to it
(BreakpointList::Add at lldb/source/Breakpoint/BreakpointList.cpp:31 in
release/22.x, and Remove at :41-57 leaves m_next_break_id alone), so nothing
bounds the loader breakpoint's id. Enough internal breakpoints created, or
created and removed, before DynamicLoaderPOSIXDYLD::DidAttach and it sits
past -15: the comprehension matches nothing, says nothing, and the orphaned
int3 is back.
Enumerate the ids from `breakpoint list --internal`, keep the symbol test as
the selector, and print what was found and what was dropped so that an empty
selection is visible in c_stacktraces.log instead of silent.
Measured on lldb 21.1.8 and on lldb 22.1.8, the version the test images
install (ci/docker/test-base/Dockerfile pins LLVM_VERSION=22):
- 171-thread debug server, real attach: `internal breakpoints [-1, -2],
dropped [-2]`, the JIT hook at -1 left in place, 3719 backtrace frames in
both arms, and `breakpoint list --internal` costs 7.2 ms on the first call
and 0.1 ms after, for 523 characters of output.
- Fresh victim per arm under the harness's SIGKILL teardown: with the window
narrowed so the loader breakpoint falls outside it, the byte at
`_dl_debug_state` goes 0xf3 -> 0xcc, the victim takes SIGTRAP, and nothing
is printed. Reading the ids keeps the byte at 0xf3.
- Two mutations, a typo'd symbol and a broken enumeration, both leave the
loader breakpoint in place, orphan the byte, and print `dropped []`.
The two versions render the loader breakpoint differently, lldb 22 as
`names = {...}` where 21 uses `address = ...`, so the leading `-N:` id is what
is parsed; it is common to both. There is no floor-free alternative in the SB
API: SBTarget.GetNumBreakpoints() returns 0 while the internal breakpoint
exists, and walking down from -1 to the first invalid id stops early because
Remove leaves holes.
| 'hit=[i for i in ids if "dl_debug_state" in str(t.FindBreakpointByID(i)' | ||
| ".GetLocationAtIndex(0).GetAddress().GetSymbol().GetName())]; " | ||
| 'print("internal breakpoints %s, dropped %s"' | ||
| " % (ids, [i for i in hit if t.BreakpointDelete(i)]))" |
There was a problem hiding this comment.
This still degrades back to the old bug when the breakpoint list --internal parser or the dl_debug_state symbol match stops working: hit == [] only changes the text we print here, and the backtrace still runs with the loader breakpoint armed. That re-exposes the original orphaned-SIGTRAP failure on the next lldb/LLVM_VERSION output drift.
Since the current tree no longer carries the focused regression test that originally guarded this parser/selector, please either keep a small automated test for this command shape (for example against captured lldb 21/22 output) or make "could not delete the rendezvous breakpoint" an explicit failure instead of a logged no-op.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #113899
Requested by @ alexey-milovidov there (a carrier, not the cause):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113899&sha=340f0cc42a1ded689ad00156688922d25bc7ffef&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
Received signal 5with_dl_debug_statein the stack is a debugger artifact, not a server fault,yet the server dies for it. On attach lldb writes one
0xccover_dl_debug_statein the runningserver's text (its shared-library-event breakpoint), and only the debugger that wrote it restores
it: the
subprocess.runtimeout path isprocess.kill(), and a process-groupSIGTERM, anexception unwind and an
abort()are no gentler. A laterdlopenexecutes the orphanedint3,raising
SIGTRAPwithsi_code = SI_KERNEL, whichSignalHandlers.cppreports as fatal. In thelinked job, worker 0's timed-out
lldbon server 2885 precedes that server's trap, in anotherworker's test, by 21 minutes.
The fix deletes that breakpoint right after attach, so no later kill can orphan it. Candidate ids
come from lldb's own internal list, since internal ids decrement from 0 and are never recycled and
no fixed range bounds them; the symbol test picks the loader out of the JIT and sanitizer hooks, and
the command prints what it dropped, so an empty selection shows. A genuine
SIGTRAPstays fatal.Master's per-PID budget (my #114565) merges here unchanged: a higher ceiling times out less often
but cannot un-orphan a byte.
Validated on a real 171-thread server under the harness's exact SIGKILL teardown, on debug and
ASan+UBSan builds, on lldb 21.1.8 and on the 22.1.8 the test images install: the byte ends
0xccwithout the change and stays
0xf3with it, and the backtrace is unchanged. A failedscriptcommand is inert:
--batchstill produces the dump.CIDB today: 22
_dl_debug_statereports over 180 days across 22 PRs, all sanitizer builds; thetrigger is still live, at 29
lldb ... timed outrows across 27 PRs in the last 30 days, newest2026-09-02.
Version info
26.10.1.265-master(included in26.10and later)