Skip to content

fix(linux): report a missing display instead of dying in uv_close - #15084

Merged
nwparker merged 10 commits into
nwparker/linux-cli-launch-redirectfrom
nwparker/linux-headless-display-diagnosis
Sep 2, 2026
Merged

nwparker merged 10 commits into
nwparker/linux-cli-launch-redirectfrom
nwparker/linux-headless-display-diagnosis

Conversation

@nwparker

@nwparker nwparker commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​745 $\color{#cf222e}{\Huge{\mathbf{−}}}$​351 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​394
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251 $\color{#cf222e}{\Huge{\mathbf{−}}}$​66 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185

ELI5

On headless Linux, Chromium can print a missing-display error and then segfault while tearing down its half-initialized state. Orca now validates the selected X11 or Wayland endpoint before Chromium starts and exits with actionable guidance. The bundled CLI also gains a real --version path that does not need a display.

What Changed

Display preflight

  • Packaged, non-serve Linux launches call hasUsableLinuxDisplay() before Chromium initialization.
  • Local X11 values require a socket plus a live lock PID; EPERM correctly means the server exists under another user.
  • Local Wayland values require an absolute runtime directory and a socket.
  • Explicit --ozone-platform / ELECTRON_OZONE_PLATFORM_HINT selection is honored.
  • Remote and SSH-forwarded X display names are left to Chromium because they cannot be proven with a local socket check.
  • Missing, blank, stale, or platform-mismatched endpoints exit 1 with X11/Wayland and distro-specific Xvfb guidance.
  • serve remains excluded: it owns its existing Xvfb bootstrap, and its offscreen windows specifically require X11.

CLI version

  • Standalone --version and -v read the version stamped into the unpacked compiled-output package boundary.
  • Build verification writes the repository version; afterPack replaces it with appInfo.version, preserving hourly/daily/adhoc channel accuracy.
  • Missing, malformed, or non-string version metadata fails closed with a clear non-zero result.

Why

#13719's uv_close() backtrace is teardown, not the root cause. The sequence is:

Missing X server or $DISPLAY
The platform failed to initialize. Exiting.
Segmentation fault (core dumped)

A plain GUI launch and a CLI-shaped launch that falls through to Chromium have the same failure. Starting an invisible desktop for non-serve launches would be misleading, so Orca reports the unavailable display instead. orca-ide serve remains the supported headless service path.

Linked Issue

Fixes #13719
Fixes #9212
Refs #17615 (the separate headless serve X11/Xvfb requirement)

Visual Proof

N/A — command-line behavior only; the exact before/after transcript is included below.

Before / after

# Before
$ ./orca-ide --no-sandbox
The platform failed to initialize. Exiting.
Segmentation fault (core dumped)
$ echo $?
139

# After
$ ./orca-ide --no-sandbox
Orca needs a usable display server, but the selected X11 or Wayland endpoint is unavailable.
...
$ echo $?
1

The supported launcher reports the packaged build without Chromium:

$ ./squashfs-root/resources/bin/orca-ide --version
1.4.178-rc.2

Testing

  • 5 changed test files / 66 tests
  • pnpm tc:node
  • pnpm tc:cli
  • changed-code quality, full lint/readiness gates, and git diff --check

Stack readiness evidence on the published rebased stack (main@212c0e42): 56 changed test files, 785 tests passed, and 4 platform-gated skips. Typecheck, reliability/max-lines/runtime-Electron ratchets, changed-code quality/React Doctor, formatting, oxlint, shellcheck, and git diff --check passed. The full-suite control run had 7 failures in 3 untouched files: the zsh non-ASCII wrapper rename collision, the SSH host-key mock's missing ssh2.utils, and a renderer context-menu failure seen only in the full run (the isolated test passed). The zsh and SSH failures reproduce on pristine origin/main; fresh CI is running on the published heads.

Coverage includes live/stale/absent X11, another user's X server, Wayland sockets, forced Ozone selection, remote and SSH-forwarded X displays, non-Linux gating, Xvfb fallback, effective-version stamping, and malformed version metadata.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

PR 3 of 7, stacked on #15083.

  1. fix(linux): give the CLI one entrypoint by extracting the AppImage once #15081 — one stable AppImage CLI entrypoint
  2. fix(linux): stop CLI commands from falling through to Chromium startup #15083 — unified launch redirect
  3. fix(linux): report a missing display instead of dying in uv_close #15084 — missing-display diagnosis and CLI version
  4. test(linux): add a packaged-artifact contract for the CLI launch paths #15085 — packaged-artifact launch contract and rpm parity
  5. fix(linux): require static AppImage runtimes #17319 — static AppImage runtime validation
  6. fix(linux): move deb/rpm update installation outside Orca #17318 — manual deb/rpm package installation handoff
  7. docs(linux): document orcad update restart safety #17320 — orcad restart-ownership safety documentation

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • No wire, mobile, persistence, or provider contract changes; no mobile-facing RPC/protocol/pairing surface was touched.

  • The display gate is packaged-Linux-only and inert on macOS/Windows.

  • SSH-forwarded displays are preserved rather than rejected as missing local sockets.

  • Version stamping uses the existing unpacked package boundary; no artifact-layout migration is introduced.

  • Residual P2: a bind-mounted local X11 socket whose server PID is outside the container namespace cannot be proven live; an in-container Xvfb or nonlocal DISPLAY form remains the practical workaround.

Checklist

  • Rebased onto fix(linux): stop CLI commands from falling through to Chromium startup #15083
  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

User-facing regressions

Not zero. One class remains unfixed.

1. Abstract-namespace X sockets and WAYLAND_SOCKET fd handoff are refused. Removed. Abstract addresses are kernel-owned and vanish when their owner exits, so an entry in /proc/net/unix is proof of a live server — no lock file needed and no stale entry possible (verified on Ubuntu 24.04, where 139 such addresses were present). WAYLAND_SOCKET is an already-connected fd, so its presence is the display. Both are consulted only after the filesystem-socket check fails, so no existing verdict changes.

  1. orca serve exits 1 rather than running degraded when DISPLAY is set but not verifiably live. Workaround: unset DISPLAY and let Orca start its own Xvfb.

Verified working and explicitly not regressed: X11 over SSH (DISPLAY=localhost:10.0), XWayland, a root-owned X server (EPERM branch), absolute-path WAYLAND_DISPLAY, and the documented systemd topology (Environment=DISPLAY=:99, User=orca).

Found in review and fixed here, both confirmed on Ubuntu 24.04 hardware:

  • A working X server published without a lock file — a container bind-mounting only /tmp/.X11-unix, or WSLg — was declared dead and the app refused to start. An X server writes socket and lock together and both survive kill -9, so a lockless socket can only be a foreign endpoint. Now serves; verified at the X-protocol level with xlsclients showing Orca connected with mapped windows.
  • A stale root-owned :99 socket that serve (running as User=orca) cannot unlink caused a startup SIGSEGV: the failed removal was swallowed, readiness saw the surviving socket, and Chromium initialised Ozone against a dead display. Measured exit 139 before, clean exit 1 with a diagnosis after.

@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 4214d7d to 6ef707d Compare August 30, 2026 00:50
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 79a3eea to d191bce Compare August 30, 2026 00:50
@greptile-apps

greptile-apps Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR adds packaged-Linux display preflight checks and a bundled CLI version path, while preserving the separate Xvfb startup behavior for serve mode.

  • Validates selected local X11 and Wayland endpoints before Chromium startup.
  • Exits synchronously with display and Xvfb guidance when setup fails.
  • Stamps and reads packaged CLI version metadata.
  • Reorganizes packaged-runtime tests into a focused suite.

Confidence Score: 4/5

The PR does not appear safe to merge until the outstanding remote-display bypass is resolved, because an unreachable but syntactically valid X11 endpoint can still continue into Chromium startup.

The display helper still treats any syntactically valid nonlocal DISPLAY as usable without checking reachability, so the new startup gate does not prevent the unavailable-display failure for that existing reported path.

Files Needing Attention: src/main/startup/ensure-virtual-display.ts

Important Files Changed

Filename Overview
src/main/startup/ensure-virtual-display.ts Adds local X11 and Wayland validation and Xvfb failure handling; the previously reported remote-display reachability gap remains.
src/main/index.ts Adds synchronous pre-ready exits for failed packaged display preflight and failed serve-mode display setup.
src/cli/cli-version.ts Reads version metadata from the compiled-output package boundary and fails closed on invalid data.
src/cli/index.ts Handles standalone version flags before normal CLI dispatch.
config/electron-builder.config.cjs Stamps the effective packaged application version into the unpacked CLI metadata boundary.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  L[Packaged Linux launch] --> S{Serve mode?}
  S -->|No| P[Validate selected display]
  P -->|Unavailable| E[Print guidance and exit 1]
  P -->|Accepted| C[Continue Chromium startup]
  S -->|Yes| X[Reuse X11 or start Xvfb]
  X -->|Failure| E
  X -->|Success| C
Loading

Reviews (22): Last reviewed commit: "fix(linux): fail serve when no display i..." | Re-trigger Greptile

@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 6ef707d to 7e3a2ce Compare August 30, 2026 02:14
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from d191bce to 5efccbb Compare August 30, 2026 02:18
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 7e3a2ce to de05897 Compare August 30, 2026 03:42
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 5efccbb to 37ea874 Compare August 30, 2026 03:42
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from de05897 to 3d9f13c Compare August 30, 2026 04:23
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 37ea874 to 444495a Compare August 30, 2026 04:23
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 3d9f13c to ec38c08 Compare August 30, 2026 04:57
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 444495a to a78c63e Compare August 30, 2026 04:58
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from ec38c08 to 3375af7 Compare August 30, 2026 05:09
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from a78c63e to 79e6426 Compare August 30, 2026 05:09
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 3375af7 to 746490c Compare August 30, 2026 05:15
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 79e6426 to 362b942 Compare August 30, 2026 05:16
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 746490c to a3d0e25 Compare August 30, 2026 06:26
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 362b942 to b39dec3 Compare August 30, 2026 06:34
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from a3d0e25 to 7350a97 Compare August 30, 2026 08:29
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from b39dec3 to 33178fb Compare August 30, 2026 08:30
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 7350a97 to 6f3166e Compare August 30, 2026 08:35
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 33178fb to ca74174 Compare August 30, 2026 08:35
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 6f3166e to 1e152b9 Compare August 30, 2026 08:58
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from ca74174 to 6cd118b Compare August 30, 2026 08:58
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 1e152b9 to e40c806 Compare August 30, 2026 09:21
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 6cd118b to 9b360ae Compare August 30, 2026 09:21
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from e40c806 to a91f7e9 Compare August 30, 2026 23:43
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from 2bc13e6 to e7c373b Compare August 31, 2026 05:19
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from eb477d9 to 2f1a4c2 Compare August 31, 2026 05:19
@nwparker

Copy link
Copy Markdown
Contributor Author

Follow-up boundary: issue #17615 confirms that orca serve on a genuinely headless host still requires a live X11/Xvfb server and can fail before JavaScript startup. This PR intentionally keeps serve on its existing Xvfb/X11 path; its preflight only covers non-serve packaged launches. Please track the true headless-server path in #17615 rather than treating this change as a fix for that issue.

@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from e7c373b to aba62d5 Compare August 31, 2026 11:59
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 2f1a4c2 to 759ff29 Compare August 31, 2026 12:00
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from aba62d5 to 000f798 Compare August 31, 2026 13:03
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 759ff29 to 7e7ca31 Compare August 31, 2026 13:03
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 000f798 to d06b724 Compare September 1, 2026 09:14
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 7e7ca31 to 6cc0b29 Compare September 1, 2026 09:16
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from d06b724 to 5435a61 Compare September 1, 2026 10:07
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 6cc0b29 to 8af9245 Compare September 1, 2026 10:07
An X server writes its lock beside its socket and both survive a crash
(verified against Xvfb under SIGKILL), so a socket with no lock was never
left by a crashed server. It is an endpoint published from elsewhere: a
container bind-mounting only /tmp/.X11-unix, WSLg, or a foreign PID
namespace. Declaring those dead made the desktop gate exit(1) on displays
that work, with no workaround, and the serve gate refuse to start.

Liveness now splits by ownership. A foreign DISPLAY trusts a lockless
socket; Orca's own :99 does not, because removeStaleDisplayArtifacts
unlinks the lock before the socket and so manufactures that state itself --
adopting it would resurrect the orphan-socket bug and stop the cleanup from
self-healing. The stale-lock rejection is unchanged.

Also correct four doc statements this behaviour falsified.
Readiness only checked that /tmp/.X11-unix/X99 exists. A stale socket we
could not unlink still exists after our own Xvfb refused to bind, so Orca set
DISPLAY to a dead server and Chromium died in Ozone init.

Measured on Ubuntu 24.04 against the pre-fix build: with a leftover :99
socket and no lock, serve exits 139 (SIGSEGV), the socket inode is unchanged
before and after, and no lock is recreated -- it neither cleaned up nor
respawned. To a user that is a crash, not a misconfiguration.

This is reachable in the documented topology, where orca-xvfb.service has no
User= and runs as root while serve runs as User=orca: /tmp is sticky, so the
orca uid cannot unlink a root-owned socket, rmSync fails, and Xvfb exits with
the display already active.

Readiness now requires the display to actually be live -- our socket plus a
lock naming a running process -- so the same state reports an unusable
display and exits 1 with the existing diagnosis.
Two display setups this gate could not prove were refused outright, and on the
desktop path that is app.exit(1) with no workaround.

An X server may bind only the abstract namespace (`@/tmp/.X11-unix/X0`), which
leaves no filesystem socket to stat. Abstract addresses are kernel-owned and
vanish the moment the owner exits, so an entry in /proc/net/unix is proof of a
live server -- no lock file needed and no stale entry possible. Verified on
Ubuntu 24.04, where 139 such addresses were present.

WAYLAND_SOCKET is an already-connected fd handed over by the compositor, so
there is no path to stat and WAYLAND_DISPLAY may be unset entirely. Its
presence is the display.

Both are consulted only after the filesystem-socket check fails, so no
existing verdict changes.
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 5435a61 to 4f90ecf Compare September 1, 2026 10:28
@nwparker
nwparker force-pushed the nwparker/linux-headless-display-diagnosis branch from 8af9245 to ee41ace Compare September 1, 2026 10:28
Recognising a lockless X socket as live is correct for an endpoint published
from elsewhere -- a container bind mount, WSLg -- because an X server writes
its lock beside its socket and both survive a crash. It is wrong for
VIRTUAL_DISPLAY_NUMBER, because Orca's own teardown unlinks the lock before
the socket and so manufactures that exact state.

The managed branch was already strict, but a caller that sets DISPLAY=:99
explicitly takes the foreign path and skipped it, accepting a dead display
left by Orca's own interrupted cleanup. Route the managed number through the
strict probe on both paths.

Found by an adversarial audit of the asymmetry introduced earlier in this
branch; the documented systemd topology is unaffected because its Xvfb writes
a real lock.
@nwparker
nwparker merged commit dcf5938 into nwparker/linux-cli-launch-redirect Sep 2, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant