-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
macOS: per-port lsof port-health polling can saturate launchservicesd and trigger a WindowServer watchdog reboot #90548
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Summary
On macOS, the gateway's port-health checks spawn
lsofonce per inspected port on every poll cycle. On a busy machine this steady stream of short-lived process launches can saturate macOS's launch pipeline (syspolicydGatekeeper assessment +launchservicesdcheck-in) badly enough thatlaunchservicesdhits its 512 dispatch-thread hard limit. When that happens,WindowServerblocks on a synchronous LaunchServices XPC call, goes unresponsive, and the OS watchdog (watchdogd) kills it — which tears down the graphics session and looks to the user like a freeze + reboot.I traced a hard "froze and rebooted" event on my Mac to exactly this.
Environment
KeepAliveLaunchAgent (com.clawdbot.gateway), node, port 18789latest2026.1.24-3)What I observed
dist/infra/ports-inspect.jsruns, per port:In the macOS unified log, the gateway spawned
lsoflike clockwork — one invocation every ~2.2 seconds, sustained (≈27/min, consistent with iterating the gateway's service ports across the ~60s poll interval). Each spawn forces a full launch pipeline pass:syspolicydGatekeeper/notarization assessment (I measured ~41 assessments/sec across the system during the incident window)launchservicesdCHECKIN+ code-signing verificationRoot-cause chain (from Apple's own crash captures)
The
WindowServer-*.userspace_watchdog_timeout.spinreport states verbatim:and WindowServer's main-thread stack at the time was:
Caveat / honesty
My host was heavily loaded, which lowered the threshold — openclaw is unlikely to do this on an idle machine. But a per-minute, per-port
lsofsweep is a lot of process-launch pressure on macOS specifically (every exec hits Gatekeeper + LaunchServices), so it's a real contributing factor worth hardening.Suggested mitigations
lsofper cycle, not one per port. A singlelsof -nP -iTCP -sTCP:LISTENlists all listening TCP sockets at once; parse it for the ports of interest. This collapses ~27 spawns/cycle to 1.node:net) and reservelsoffor the "who owns this port?" detail path only when a conflict is detected.sswhenlsofis missing #14083 added assfallback on Linux; the macOS path could similarly minimizelsoffan-out.Related
lsofstat() is slow (SMB) — same tool, different triggerlsofstale-pid scan when not installedsswhenlsofis missing #14083 — Linux: fall back tosswhenlsofmissing