Repository navigation
[Bug]: Desktop main process SIGTRAPs during preview_open webview attach / debugger.attach #8332
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/desktop
Steps to reproduce
Not a guaranteed crash (race). Observed sequence on macOS desktop:
- Desktop app has been running for hours, window in the background.
- Agent calls
preview_status. Host is connected, but there is no tab yet:available=true,visible=false,tabId=null. - Agent calls
preview_openwith an HTTPS URL (in this case a third-party login/deep-control page). That creates a new Loading session and mounts a<webview src=url>(including offscreen). - Renderer registers the guest from
did-attach/dom-readyviapreviewBridge.registerWebview. - Main-process
PreviewManager.registerWebviewmutates the guest (zoom/mute/listeners) andrunForksrestoreControlSession→wc.debugger.attach("1.3")without waiting and without anisDestroyed()/ generation gate. - Overlay wait treats
automation.statusavailable=trueas soon as the WebContents exists, which is before CDP attach finishes.
Related: #8221 is a generic macOS 26 periodic crash with no stack. This report is a specific CrBrowserMain SIGTRAP tied to preview open.
Expected behavior
preview_open should either succeed or return a typed automation error. The Electron main process should not abort.
Actual behavior
Main process dies with EXC_BREAKPOINT (SIGTRAP) on Thread 0 CrBrowserMain. The in-flight MCP preview_open then surfaces as:
Preview automation client <id> disconnected during open.
(PreviewAutomationClientDisconnectedError — the host stream is dropped because the app died, not because the broker race itself SIGTRAPs.)
The app relaunches afterward. The disconnect/open broker race is JS-only and is already tested; it cannot fatal-check Electron by itself.
Impact
Blocks work completely
(Hard abort of the whole desktop app, including the bundled server. Intermittent, but any cold preview_open of a new HTTPS guest can hit it.)
Version or commit
Desktop 0.0.34, Electron 41.5.0. Preview manager at fe281c540 (fix(desktop): throttle hidden preview rendering (#7445)). Captured on a personal-branded Mac build; the crashing preview attach / CDP path is unmodified upstream desktop code.
Environment
macOS 26.2 (25C56), Apple Silicon (MacBookAir10,1), T3 Code desktop wrapping the shared web client. Crash Role was Background. Process had been up ~8.6 hours.
Logs or stack traces
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Triggered by Thread: 0 CrBrowserMain
Termination Reason: Namespace SIGNAL, Code 5, Trace/BPT trap: 5
Reliable frames (Electron Framework is stripped; large +NNNN offsets are neighboring names):
NSApplication run
→ Electron main loop
→ node::InternalMakeCallback
→ v8::Function::Call
→ immediate crash
No Application Specific Information / CHECK text in the macOS report.
Full sanitized macOS crash report (personal bundle id removed):
https://gist.github.com/bald-ai/3d8c2a7a5d425fe743c26216ca8ffc75
Investigation (source, not a patch)
Proven:
- Cold
preview_openwith a URL creates a Loading snapshot (apps/server/src/preview/Manager.ts) andElectronBrowserHostmounts a<webview>for every session, including offscreen (apps/web/src/browser/HostedBrowserWebview.tsx). - Registration runs on
did-attach(GuestView still attaching). apps/desktop/src/preview/Manager.tsregisterWebviewUnlockedcallssetZoomFactor/setAudioMuted/attachListeners, thenrunFork(restoreControlSession).ensureControlSession/restoreControlSessioncalldebugger.attach("1.3")with noisDestroyed()check.attempt()only catches thrown JS; ChromiumCHECK/ImmediateCrashisSIGTRAPon arm64.- Overlay
availableis “guest exists”, not “CDP attached” (automationStatus). setWindowOpenHandlerdenies popups andloadURLs them into the same guest, which can navigate during attach.PreviewAutomationClientDisconnectedErroris raised when the host stream is removed (apps/server/src/mcp/PreviewAutomationBroker.ts). Automation subscriptions useidleTtlMs: 0.
Inferred (high): the SIGTRAP is a GuestView / DevToolsAgentHost fatal check during attach or a concurrent loadURL/setZoomFactor/debugger.attach. Exact CHECK name unknown (stripped symbols).
The broker disconnect-during-open path does not SIGTRAP. The guest-open work running at the same time can.
Likely smallest fix (not implemented here): gate debugger.attach / sendCommand / setZoomFactor / loadURL on !wc.isDestroyed() + current tab generation; await control-session attach under the tab lifecycle lock instead of runFork. Registering only on dom-ready, or attaching CDP lazily on first command that needs it, would also shrink the window. Retrying preview_open on ClientDisconnectedError would not stop the abort.
Workaround
Avoid preview_open of a new tab to an HTTPS login/redirect-heavy URL while the desktop window is in the background. Reusing an already-attached tab is much less likely to hit this. After a crash, relaunch and continue; no evidence this corrupts the sqlite store, but that is not proven.
Activity
bald-ai commentedon Aug 26, 2026
This bug happened to me and agent said its not caused by my fork and fixable. So I asked it to post it here, hope it helps. If not delete, I dont care.
ibniss commentedon Aug 28, 2026
I hit a similar issue where t3 code crashed while the agent was using the built-in browser tools. Had my agent look into the error dump and found this issue as potentially related. I'm adding the details from my case in case they help narrow down the underlying issue, here's a summary of the investigation by 5.6 Sol:
Apologies if this turns out to be unrelated, happy to move it to a separate issue and remove the comment if so.
albertojb commentedon Sep 3, 2026
Linux reproduction of the same SIGTRAP-in-CrBrowserMain / debugger.attach crash.
Environment:
Timestamp: 2026-09-03 18:44:13 EDT
Core: coredumpctl PID 109965 (351.2M)
Backtrace (frame 0 only, stripped): t3code + 0x8d75c91 → t3code + 0x42e1ccd → t3code + 0x4cfcbb9 → t3code + 0x7cb0567 → t3code + 0x5878c2b (no symbols)
Different trigger from the macOS case (not preview_open of an HTTPS login page while backgrounded). Crash was on a cold start, so the likely cause is the same root issue: debugger.attach / CDP lifecycle without an isDestroyed() or generation gate hitting a Chromium CHECK/ImmediateCrash. Useful to know whether the fix gates apply to the Gtk build too.
Filed by opencode via static-best-coding.
Kabilan108 commentedon Oct 6, 2026
Adding a Linux crash report that may be related. I authorized Codex to investigate and post this comment. The native failure appears to be in Chromium navigation-origin validation, so I am not claiming this is the same debugger.attach race as the original report.
Environment and impact
0.0.46-nightly.20261005.2676, verified from the packagedpackage.json.26.11.20261001.c59305b; Linux6.18.54, x86_64.--ozone-platform=wayland.--password-store=gnome-libsecret. No--no-sandboxargument in the recorded main-process command line.systemd --user, matching the separate lifecycle issue [Bug]: Desktop backend outlives a crashed main process and keeps its port, so the relaunch silently moves to another port #13747. No claim about database corruption or data-loss testing.Observed sequence, not a deterministic repro
The app had been running for about 68 minutes, with agent-driven embedded-preview automation active. No deliberate reproduction has been attempted against the daily profile. Window foreground/background state at the instant of the crash was not captured.
The desktop trace records:
PreviewManager.navigatefails duringnavigate.normalizeUrl. The nested cause isPreviewUrlNormalizationError: Invalid preview URL (parse: https:; input length 11)andTypeError: Invalid URL. This is a recorded, handled Effect failure. It is not evidence that this exception directly caused the native crash.requireWebContents,ensureControlSession,sendCommand,performAutomationEvaluate,automationEvaluate, andautomationStatuscomplete successfully.0.0.46-nightly.20261005.2702available. There is no captured evidence of update installation.int3trap and systemd captures a core dump.The exact URL/frame that was navigating when the native check failed is not yet known. A failing preview operation about 16 seconds earlier, or a successful update check about 2 seconds earlier, establishes timing, not causation.
Native evidence
Sanitized kernel line:
Systemd reports
Signal: 5 (TRAP)and a present core dump, compressed size about 78.8 MiB. Its unwound main-thread frames are stripped; representative executable-relative offsets:GDB confirms the trap instruction at executable offset
0x40a7e52, followed byud2at0x40a7e53. Disassembly shows a call at0x40a7853to0x3f29ca0, testing its Boolean result and branching to that trap if false:The containing function references these diagnostic strings:
Those strings and the check structure match Chromium's
NavigationRequest::GetOriginForURLLoaderFactoryAfterResponse(), which checks that the target renderer is permitted to commit the chosen origin throughChildProcessSecurityPolicyImpl::CanAccessOrigin(...):https://chromium.googlesource.com/chromium/src/+/refs/heads/main/content/browser/renderer_host/navigation_request.cc
Inference: the crash is consistent with that navigation-origin security CHECK. This is a source/disassembly match, not a fully symbolicated stack against the exact bundled Chromium revision. GDB could not recover a useful full backtrace; the offsets above are from systemd's unwind.
Other checks and available diagnostics
/dev/null. The existingdesktop-main.logwas historical, so it did not provide this crash's native CHECK message. Current evidence comes from the core dump, system journal, anddesktop.trace.ndjson.Is this navigation-origin CHECK best tracked here, or should it be a separate issue? A reliable reproduction and the exact failing origin remain missing.
t3dotgg commentedon Oct 21, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the report. One part of this is fixed on main in #9068. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: later crashes possibly unrelated to the original attach race. If that part still matters to you, please open a new issue for that part only.