orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: [Windows] Crash on startup since 1.4.32 — heap corruption (c0000374) in ntdll during native module init (regression, 1.4.3 works)

Open MrViSiOn opened this issue 6 months ago • 5 comments

Operating system

Windows

Orca version

1.4.32.0 / 1.4.33 (crash), 1.4.34 (crash), 1.4.35 (crash); last known good: 1.4.3

Details

Operating system

Windows

Orca version

1.4.32.0 / 1.4.33.0 (crash) / 1.4.34.0 (crash) / 1.4.35.0 (crash); last known good: 1.4.3

Details

Describe the bug

Orca crashes a few seconds after launch, every time. The window appears briefly, then closes. Reproducible 100% of the time. Reinstalling and wiping %APPDATA%\orca does not help.

This is a regression: version 1.4.3 runs fine and stable, but 1.4.32, 1.4.33 1.4.34 1.4.35 crash on the same machine.

Environment

  • Affected versions: 1.4.35.0, 1.4.34.0, 1.4.33.0 (crash). Last known good: 1.4.3 (stable)
  • OS: Windows 11 Pro, build 26200 (verbld=26200, ubr 8457)
  • RAM: 64 GB

Crash signature (Windows Event Viewer / WER)

  • Faulting module: ntdll.dll (10.0.26100.8328)
  • Exception code: 0xc0000374 (heap corruption)
  • Faulting offset: identical on every crash (0x117175)
  • WER bucket: ca73297130f9a1744468adeee883d1a4

What I've ruled out

  • Not GPU-related: crashes the same with --disable-gpu, --disable-gpu-compositing, --no-sandbox, --disable-software-rasterizer.
  • Not a corrupt config: wiped %APPDATA%\orca and %APPDATA%\orca\daemon, fresh reinstall — same crash.
  • Not an injected 3rd-party DLL: the WER loaded-module list is clean — only Windows DLLs plus Orca's own native modules. No AV/overlay DLLs present.

Likely culprit

The only non-Windows modules loaded at crash time are Orca's native addons:

  • resources\app.asar.unpacked\node_modules\node-pty\build\Release\conpty.node
  • resources\app.asar.unpacked\node_modules\cpu-features\build\Release\cpufeatures.node

The crash coincides with PTY/daemon init. Earlier launches logged: Failed to start daemon PTY provider, falling back to local: Daemon exited during startup with code 1

Looks like a node-pty / ConPTY heap corruption during startup on recent Windows 11 builds (26200), introduced between 1.4.3 and 1.4.32.

Steps to reproduce

  1. Install Orca 1.4.32 or 1.4.33 on Windows 11 build 26200
  2. Launch
  3. App opens, then crashes within seconds with c0000374

Workaround

Downgrading to 1.4.3 resolves it.

I can provide the full WER report, the .dmp, or stderr logs if useful.

MrViSiOn avatar May 31 '26 08:05 MrViSiOn

Hey @MrViSiOn will prioritize this! @Jinwoo-H will look as soon as he's awake

I'd look now, but my Windows machine is dead (and my new one arrives Tuesday 🥲)

nwparker avatar May 31 '26 08:05 nwparker

Hi @nwparker, thank you so much!!!! I will stay in 1.4.3 in the meantime :)

MrViSiOn avatar May 31 '26 08:05 MrViSiOn

Investigation Summary

I investigated this heap corruption crash on Windows 11 build 26200. Here are my findings:

Root Cause Analysis

The crash appears to be a double-close issue in node-pty's Windows ConPTY implementation:

  1. \WindowsTerminal.destroy()\ calls \kill()\ internally (windowsTerminal.js:141-146)
  2. \kill()\ calls _agent.kill()\ which invokes \ his._ptyNative.kill(this._pty, ...)\ (native ConPTY kill)
  3. If \kill()\ is called before \destroy(), the native kill runs twice
  4. This double-close of the ConPTY handle can cause heap corruption in ntdll.dll

Evidence

From \hidden-pty-cleanup.ts:26-30: \\ ypescript // Why: node-pty WindowsTerminal.destroy() calls kill() again, which can // close the same ConPTY handle twice after an intentional termination. if (process.platform === 'win32') { return } \\

Orca already has guards against this pattern, but there may be race conditions during daemon startup.

Why This Affects Windows 11 Build 26200

Windows 11 24H2 (build 26200) may have changes to the ConPTY API that make the double-close more likely to trigger heap corruption. Earlier builds might silently tolerate this.

Reproduction Path

The crash happens during PTY/daemon init because:

  1. Daemon forks and loads \conpty.node\
  2. Initial PTY spawn triggers ConPTY handle allocation
  3. If any error occurs during init, cleanup calls both \kill()\ and \destroy()\
  4. Double-close corrupts the heap

Suggested Fixes

Short-term (Orca-side):

  • Add explicit guard in daemon PTY cleanup to never call both \kill()\ and \destroy()\ on Windows
  • Wrap all \pty.spawn()\ calls in try-catch with careful cleanup that only calls \destroy()\ (not \kill()\ first)

Long-term (upstream):

  • Report to node-pty maintainers: \WindowsTerminal.destroy()\ should check if \kill()\ was already called
  • Or: \WindowsPtyAgent.kill()\ should be idempotent (track if already killed)

Environment Details

  • node-pty version: 1.1.0 (with Orca patches)
  • Electron version: 42.3.0
  • Affected: Windows 11 build 26200 (24H2)
  • Last known good: Orca 1.4.3

Next Steps

This requires either:

  1. Native C++ debugging with WinDbg to confirm the exact crash location in conpty.node
  2. Testing on Windows 11 26200 to reproduce and verify fixes
  3. Upstream node-pty fix for idempotent kill/destroy

I don't have access to a Windows 11 26200 test environment, so I'm documenting my findings for maintainers who can reproduce this.

sudoeren avatar May 31 '26 13:05 sudoeren

@Jinwoo-H should this be fixed now and closed?

nwparker avatar Jun 02 '26 08:06 nwparker

Yes! It works now! 1.4.38 is working perfectly!

Thank you so much!

MrViSiOn avatar Jun 02 '26 08:06 MrViSiOn