The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): extend the #38216 sandbox fallback ladder to Linux (#121954)
Yuan Li062a003a09eb
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 48026b85d6c..33b8cca271f 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -998,7 +998,15 @@ let windowsSandboxFallbackSticky = falselet windowsSandboxFallbackReason: SandboxFallbackReason = 'boot-loop'let windowsNoSandboxRelaunchAttempted = false-if (IS_WINDOWS) {+// #121954: the two-strike boot-abort ladder now also covers Linux. On Linux+// hosts where the sandboxed GPU child cannot start (dies pre-main on an+// FD-ownership violation), Chromium prints "GPU process isn't usable.+// Goodbye." and aborts — a 100% crash loop; the host isolation matrix in+// #121954 shows only `--no-sandbox` reaches the UI. Same sticky per-version+// recovery as #38216: two consecutive mid-boot aborts engage `--no-sandbox`,+// an app update re-probes the sandbox once. Windows-only extras (ACL repair,+// renderer crash-loop relaunch) stay inside the IS_WINDOWS branch.+if (IS_WINDOWS || process.platform === 'linux') {const windowsUserData = app.getPath('userData')const priorMarker = readSandboxMarker(windowsUserData)@@ -1036,7 +1044,7 @@ if (IS_WINDOWS) {app.commandLine.appendSwitch('no-sandbox')process.env.ELECTRON_DISABLE_SANDBOX = '1'console.log(- `[hermes] Windows sandbox fallback enabled (${sandboxDecision.reason}); launching with --no-sandbox (#38216)`+ `[hermes] sandbox fallback enabled (${sandboxDecision.reason}); launching with --no-sandbox (#38216, #121954)`)}@@ -1067,7 +1075,7 @@ if (IS_WINDOWS) {}console.warn(- `[hermes] Windows GPU sandbox crashed (exit=${details?.exitCode}); relaunching once with --no-sandbox (#38216)`+ `[hermes] GPU child died with the sandbox signature (exit=${details?.exitCode}); relaunching once with --no-sandbox (#38216, #121954)`)try {@@ -15187,11 +15195,12 @@ function createWindow() {}}- // #38216: clear the mid-boot marker only after a window is actually usable.- // Keep sticky `fallback` when we launched with --no-sandbox so the next- // Start Menu click does not re-enter the GPU FATAL crash loop. The marker- // records the app version so the next update re-probes the sandbox.- if (IS_WINDOWS) {+ // #38216/#121954: clear the mid-boot marker only after a window is+ // actually usable. Keep sticky `fallback` when we launched with+ // --no-sandbox so the next launcher click does not re-enter the GPU+ // FATAL crash loop. The marker records the app version so the next+ // update re-probes the sandbox.+ if (IS_WINDOWS || process.platform === 'linux') {try {writeSandboxMarker(app.getPath('userData'),@@ -19592,7 +19601,7 @@ app.on('before-quit', event => {// FATAL GPU aborts skip before-quit, leaving the `booting` marker in place.// Keyed on sticky (not active): a manual --no-sandbox run still records a// clean quit, while an engaged fallback keeps its sticky marker.- if (IS_WINDOWS && !windowsSandboxFallbackSticky) {+ if ((IS_WINDOWS || process.platform === 'linux') && !windowsSandboxFallbackSticky) {try {writeSandboxMarker(app.getPath('userData'), markerAfterSuccessfulBoot({ fallbackActive: false }))} catch {diff --git a/apps/desktop/electron/windows-sandbox-fallback.test.ts b/apps/desktop/electron/windows-sandbox-fallback.test.tsindex 1b24aaa1769..dab14fc9d9c 100644--- a/apps/desktop/electron/windows-sandbox-fallback.test.ts+++ b/apps/desktop/electron/windows-sandbox-fallback.test.ts@@ -10,6 +10,7 @@ import {alreadyHasNoSandbox,BOOT_ABORTS_BEFORE_FALLBACK,buildIcaclsGrantArgs,+ GPU_CHILD_SANDBOX_SIGTERM_EXIT,buildNoSandboxRelaunchArgs,decideWindowsSandboxLaunch,fallbackMarker,@@ -42,8 +43,8 @@ test('alreadyHasNoSandbox honors argv and ELECTRON_DISABLE_SANDBOX', () => {assert.equal(alreadyHasNoSandbox(['--disable-gpu'], {}), false)})-test('decideWindowsSandboxLaunch stays off outside Windows and on clean markers', () => {- assert.equal(decideWindowsSandboxLaunch({ platform: 'linux', marker: { state: 'booting' } }).enable, false)+test('decideWindowsSandboxLaunch stays off outside Windows/Linux and on clean markers', () => {+ assert.equal(decideWindowsSandboxLaunch({ platform: 'darwin', marker: { state: 'booting' } }).enable, false)const cleanOk = decideWindowsSandboxLaunch({platform: 'win32',@@ -364,3 +365,107 @@ test('buildNoSandboxRelaunchArgs appends a single --no-sandbox flag', () => {'--no-sandbox'])})++// #121954: Linux hosts where the sandboxed GPU child cannot start crash-loop+// 100% ("GPU process isn't usable. Goodbye."); only --no-sandbox reaches the+// UI. Same two-strike sticky ladder as #38216, minus the Windows-only extras.+test('linux boot-abort ladder engages --no-sandbox on the second consecutive abort (#121954)', () => {+ const argv: string[] = []+ const env = {}+ const appVersion = '0.21.5'++ const first = decideWindowsSandboxLaunch({+ platform: 'linux',+ marker: { state: 'booting' },+ argv,+ env,+ appVersion+ })+ assert.equal(first.enable, false)+ assert.deepEqual(first.nextMarker, { state: 'booting', bootAborts: 1 })++ const second = decideWindowsSandboxLaunch({+ platform: 'linux',+ marker: first.nextMarker,+ argv,+ env,+ appVersion+ })+ assert.equal(second.enable, true)+ assert.equal(second.reason, 'boot-loop')+ assert.equal(second.nextMarker.state, 'fallback')++ // Sticky within the same app version...+ const sticky = decideWindowsSandboxLaunch({+ platform: 'linux',+ marker: second.nextMarker,+ argv,+ env,+ appVersion+ })+ assert.equal(sticky.enable, true)+ assert.equal(sticky.reason, 'sticky-fallback')++ // ...and an app update re-probes the sandbox once.+ const reprobe = decideWindowsSandboxLaunch({+ platform: 'linux',+ marker: second.nextMarker,+ argv,+ env,+ appVersion: '0.22.0'+ })+ assert.equal(reprobe.enable, false)+ assert.deepEqual(reprobe.nextMarker, { state: 'booting', reprobe: true, bootAborts: 0 })++ const reprobeFailed = decideWindowsSandboxLaunch({+ platform: 'linux',+ marker: reprobe.nextMarker,+ argv,+ env,+ appVersion: '0.22.0'+ })+ assert.equal(reprobeFailed.enable, true)+ assert.equal(reprobeFailed.reason, 'reprobe-failed')+})++test('linux GPU SIGTERM signature triggers the one-shot relaunch; other exits do not (#121954)', () => {+ assert.equal(+ shouldRelaunchForGpuSandboxCrash({+ platform: 'linux',+ details: { type: 'GPU', exitCode: GPU_CHILD_SANDBOX_SIGTERM_EXIT, signalName: 'SIGTERM' },+ alreadyNoSandbox: false,+ relaunchAttempted: false+ }),+ true+ )+ // Non-sandbox GPU deaths (driver faults die 139/SIGSEGV) keep the sandbox.+ assert.equal(+ shouldRelaunchForGpuSandboxCrash({+ platform: 'linux',+ details: { type: 'GPU', exitCode: 139, signalName: 'SIGSEGV' },+ alreadyNoSandbox: false,+ relaunchAttempted: false+ }),+ false+ )+ // Exit 143 without the SIGTERM signal name does not fire.+ assert.equal(+ shouldRelaunchForGpuSandboxCrash({+ platform: 'linux',+ details: { type: 'GPU', exitCode: GPU_CHILD_SANDBOX_SIGTERM_EXIT },+ alreadyNoSandbox: false,+ relaunchAttempted: false+ }),+ false+ )+ // macOS has no recovery path.+ assert.equal(+ shouldRelaunchForGpuSandboxCrash({+ platform: 'darwin',+ details: { type: 'GPU', exitCode: GPU_CHILD_SANDBOX_SIGTERM_EXIT, signalName: 'SIGTERM' },+ alreadyNoSandbox: false,+ relaunchAttempted: false+ }),+ false+ )+})diff --git a/apps/desktop/electron/windows-sandbox-fallback.ts b/apps/desktop/electron/windows-sandbox-fallback.tsindex 815f47189e1..19f658b54b9 100644--- a/apps/desktop/electron/windows-sandbox-fallback.ts+++ b/apps/desktop/electron/windows-sandbox-fallback.ts@@ -5,9 +5,9 @@* (`0x80000003` / exit `-2147483645`). Chromium then FATAL-exits* ("GPU process isn't usable. Goodbye.") before the UI is usable.*- * Recovery ladder, all scoped to win32:+ * Recovery ladder:*- * 1. ACL repair (first line): grant `S-1-15-2-2` (ALL APPLICATION PACKAGES)+ * 1. ACL repair (Windows only): grant `S-1-15-2-2` (ALL APPLICATION PACKAGES)* RX on the install tree. A missing ACE plus orphan AppContainer SIDs is a* known Chromium CHECK failure (electron/electron#51761). Runs at install* time, and again at launch ONLY when the marker shows a prior aborted@@ -16,10 +16,22 @@* a signature-confirmed GPU/renderer breakpoint death, or TWO consecutive* mid-boot aborts (a single abort can be a task-manager kill or power* loss; the reported failure mode is a deterministic 100% crash loop).+ * On Linux (#121954) the evidence signal is the GPU child dying with+ * SIGTERM — Chromium's own "GPU process isn't usable. Goodbye." shutdown+ * for a GPU process that never came up — which the host matrix pinned to+ * the sandboxed GPU child (only `--no-sandbox` survives; `--disable-gpu`+ * crashes too, and the GPU child dies pre-main on an FD-ownership+ * violation before any Chromium init).* 3. The fallback is sticky per app version, not forever: after an update- * the sandbox is re-probed once (a new Electron or an installer-applied- * ACL grant may have fixed the host). If the re-probe boot aborts, the- * next launch goes straight back to `--no-sandbox`.+ * the sandbox is re-probed once (a new Electron, an installer-applied+ * ACL grant, or a kernel/driver update may have fixed the host). If the+ * re-probe boot aborts, the next launch goes straight back to+ * `--no-sandbox`.+ * 4. Windows-only extras (renderer crash-loop relaunch, ACL repair) stay+ * win32-gated: Linux has no ACL model, and its renderer crash loops carry+ * no sandbox-specific signature.+ *+ * Pure helpers stay injectable so tests never boot Electron or touch real ACLs.** Pure helpers stay injectable so tests never boot Electron or touch real ACLs.*/@@ -29,6 +41,15 @@ import path from 'node:path'export const WINDOWS_SANDBOX_MARKER_FILENAME = 'windows-sandbox-fallback.json'+/**+ * Exit status Chromium uses to SIGTERM its GPU process when it never became+ * usable (#121954: sandbox-blocked GPU child dies pre-main on an+ * FD-ownership violation, browser prints "GPU process isn't usable.+ * Goodbye." and SIGTERMs it). Node reports signal deaths as `null` exitCode+ * + `signalName: 'SIGTERM'`; Electron serializes that as exitCode 143.+ */+export const GPU_CHILD_SANDBOX_SIGTERM_EXIT = 143+/** Well-known SID for "ALL APPLICATION PACKAGES". */export const ALL_APPLICATION_PACKAGES_SID = 'S-1-15-2-2'@@ -183,7 +204,11 @@ export function decideWindowsSandboxLaunch(): SandboxLaunchDecision {const appVersion = String(options.appVersion || '')- if ((options.platform ?? process.platform) !== 'win32') {+ // The two-strike boot-abort ladder is platform-neutral (both win32 #38216+ // and linux #121954); the platform-specific helpers gate themselves below.+ const launchPlatform = options.platform ?? process.platform++ if (launchPlatform !== 'win32' && launchPlatform !== 'linux') {return { enable: false, reason: null, nextMarker: { state: 'booting' } }}@@ -339,29 +364,39 @@ export function shouldRelaunchForGpuSandboxCrash(options: {alreadyNoSandbox?: booleanrelaunchAttempted?: boolean}): boolean {- if ((options.platform ?? process.platform) !== 'win32') {+ const platform = options.platform ?? process.platform++ if (options.alreadyNoSandbox || options.relaunchAttempted) {return false}- if (options.alreadyNoSandbox || options.relaunchAttempted) {+ if (String(options.details?.type || '').toLowerCase() !== 'gpu') {return false}- const type = String(options.details?.type || '').toLowerCase()+ if (platform === 'win32') {+ return isWindowsSandboxBreakpointExit(options.details?.exitCode)+ }- if (type !== 'gpu') {- return false+ if (platform === 'linux') {+ // #121954: the sandbox-blocked GPU child never comes up; Chromium+ // SIGTERMs it (exit 143) right before its own FATAL "Goodbye." abort.+ // Deliberately narrow: GPU-only, needs the explicit signature.+ return (+ options.details?.exitCode === GPU_CHILD_SANDBOX_SIGTERM_EXIT &&+ String(options.details?.signalName || '').toUpperCase() === 'SIGTERM'+ )}- return isWindowsSandboxBreakpointExit(options.details?.exitCode)+ return false}/*** True when a renderer crash loop carries the sandbox breakpoint signature* and a one-shot `--no-sandbox` relaunch should replace the dead window- * (#38216 renderer flavor; same recovery as #56726). Gated on the breakpoint- * exit code so unrelated renderer crash loops (bad extension, OOM churn)- * don't silently drop the sandbox.+ * (#38216 renderer flavor; same recovery as #56726). Windows only: Linux+ * renderer crash loops carry no sandbox-specific exit signature, so+ * dropping the sandbox on one would be a guess.*/export function shouldRelaunchForRendererSandboxCrashLoop(options: {platform?: NodeJS.Platform | string