Repository navigation
Conversation
macOS 26 (Tahoe) libsystem_c aborts with SIGILL any forked child that performs non-async-signal-safe work (logger, malloc, mutex) before exec*(). The watchdog forks but never exec()s, so every clickhouse-server start on Darwin emits a "crashed on child side of fork pre-exec" .ips report. On Darwin, spawn a fresh server via posix_spawn and use CLICKHOUSE_WATCHDOG_CHILD as a sentinel so the re-exec'd process skips its own watchdog setup. Linux keeps the existing fork-based behavior.
|
Workflow [PR], commit [58df5d5] Summary: ❌
AI ReviewSummaryThis PR switches the Darwin watchdog path from Findings❌ Blockers
Final VerdictStatus:
|
| posix_spawnattr_setsigmask(&attr, &empty_mask); | ||
| posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK); | ||
|
|
||
| int rc = posix_spawn(&pid, orig_argv[0], &file_actions, &attr, orig_argv, environ); |
There was a problem hiding this comment.
posix_spawn here uses orig_argv[0] as the executable path. Unlike the previous fork-and-continue flow, this now depends on argv[0] being directly executable from the current working directory.
If the server is started via PATH (for example argv[0] = "clickhouse") or a relative launcher path, posix_spawn can return ENOENT even though the current process is already running correctly. That makes watchdog setup fail on Darwin for valid invocation modes.
Please spawn using a stable absolute executable path (for example getExecutablePath) or use posix_spawnp if PATH lookup is intended.
LLVM Coverage Report
Changed lines: 81.82% (9/11) | lost baseline coverage: 3 line(s) · Uncovered code |
|
Sample crash report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106340&sha=b121002f9ec1230c7618d546e1908ed0f54d534e&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29%20%5B4%5D Ips file: https://s3.amazonaws.com/clickhouse-test-reports/PRs/106340/b121002f9ec1230c7618d546e1908ed0f54d534e/fast_test_arm_darwin_4/clickhouse-2026-06-08-163726.ips The
|
|
The analysis doesn't look correct, and I don't think we need this change:
Let's instead try disabling JIT in tests on Mac, if it helps - disable JIT on Mac completely |
Every
Fast test (arm_darwin)run onmacOS 26.3.1emits an.ipscrash report with an identical signature, regardless of whether the test job itself succeeds. The root cause is the newlibsystem_chardening onmacOS 26(Tahoe), whichSIGILLs any forked child that performs non-async-signal-safe work betweenfork()andexec*().Diagnosis
98 of 99 sampled
.ipsfiles from the 100 most recent runs share the exact same signature (bug_type 309, the missing 1 was a download error):EXC_CRASH/SIGILL("Illegal instruction: 4")libsystem_c.dylib: crashed on child side of fork pre-execclickhouse(forked child ofclickhouse-server)macOS 26.3.1 (25D2128)SignalListener::waitForTerminationRequest— misleading. The actualSIGILLis delivered to the child while it is still in the post-forkpre-execwindow.The offending fork is
BaseDaemon::setupWatchdog(src/Daemon/BaseDaemon.cpp:573). The watchdog auto-enables in CI mode (no TTY on stdin/stdout/stderr, seeprograms/server/Server.cpp:508),fork()s, and the child path immediately calls non-async-signal-safe code:Jemalloc::setup,OwnAsyncSplitChannel::open,updateCurrentThreadIdAfterFork,logger().information(...), thenPoco::Pipe::readBytes. Because the child never callsexec*()(it insteadreturns fromsetupWatchdogand continues running the parent's already-initialized code), the entire child lifetime is "pre-exec" fromlibsystem_c's point of view, and the first non-AS-safe call trips the hardening check.Other forks in the server are not affected:
ShellCommand::executeImplusesvfork()and a strictly AS-safe child block (dup2,sigprocmask,execv,_exit).Poco::Process::launchis not used byclickhouse-server(no references insrc/).mainEntryClickHouseChdig,programs/docker-init, and friends are unrelated to the server runtime.Change
On Darwin only, replace the
fork()-and-continue pattern inBaseDaemon::setupWatchdogwithposix_spawn. The spawned child is a freshclickhouse-serverprocess that re-runsmainand re-initializes everything cleanly —libsystem_chas no exposed post-fork pre-exec window from userland's view, so the hardening cannot fire. A sentinel env varCLICKHOUSE_WATCHDOG_CHILD=1is set before the spawn so the re-exec'd child knows not to enable its own watchdog (otherwise watchdogs would nest infinitely).Linux is unchanged — the existing
fork-based watchdog path is kept verbatim, gated behind#if !defined(OS_DARWIN). The parent-sidewaitpidloop, signal forwarding, andsystemdnotification are untouched.Why
posix_spawnrather than explicitfork()+execv():SIGILLby adding a non-AS-safe call.errno-style code fromposix_spawnsynchronously, observable in the parent. With explicitfork+exec, AS-safety mistakes manifest as silentSIGILLonly visible in the resulting.ips.macOSspawns.The trade-off versus the existing in-memory continuation is that respawning the child requires re-parsing argv and re-reading the config file (~1-2s extra per respawn). The watchdog respawns very rarely in steady state, so this cost is acceptable. The behavioral cost is scoped to Darwin.
Reference query used to surface the universal
.ips:on
play.clickhouse.com.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes