Skip to content

fix(tts): stop x64 startup crash in ONNX NCHWc graph transformer - #39

Merged
julia-kafarska merged 1 commit into
mainfrom
fix/x64-onnx-graph-optimization
Aug 4, 2026
Merged

fix(tts): stop x64 startup crash in ONNX NCHWc graph transformer#39
julia-kafarska merged 1 commit into
mainfrom
fix/x64-onnx-graph-optimization

Conversation

@julia-kafarska

Copy link
Copy Markdown
Member

Fixes #36, fixes #37, fixes #38 — all three are the same bug.

Root cause

onnxruntime-node 1.23.2 segfaults inside NchwcTransformer while applying Level-3 (layout) graph optimisations to model_q8f16.onnx. From the Intel Mac crash report in #38:

Thread 27 Crashed:: WorkerThread
0  onnxruntime::graph_utils::IsSupportedOptypeVersionAndDomain(...)
1  onnxruntime::NchwcTransformerImpl::Transform(Node&)
2  onnxruntime::NchwcTransformer::ApplyImpl(Graph&, ...)
3  onnxruntime::GraphTransformer::Apply(...)
4  onnxruntime::GraphTransformerManager::ApplyTransformers(...)
5  onnxruntime::InferenceSession::TransformGraph(...)
6  onnxruntime::InferenceSession::Initialize()
9  InferenceSessionWrap::LoadModel(...)

It's a hard native abort (EXC_BAD_ACCESS / 0xC0000005) inside InferenceSession.create, so:

  • the JS try/catch → CPU fallback in createSessionWithFallback never gets to run,
  • crashpad is never connected, so nothing is logged and %APPDATA%\Out Loud is never created,
  • the app simply vanishes 2–3s after launch.

NCHWc is an x86-only transformer. That's why this reproduces on every x64 platform and never on Apple Silicon:

Issue Platform Symptom
#38 Intel Mac, macOS 15.7.7 crash report above
#37 Pop OS 24.04, i5-4690K, NVIDIA 970 log ends at Loaded embedded model: …model_q8f16.onnxSegmentation fault (core dumped)
#36 Windows 11 x64, AMD and NVIDIA, plus Linux Mint reproduced standalone in Node with no Electron, ["cpu"] EP

GPU vendor, DirectComposition, VC++ redistributable and Wayland/EGL are all red herrings — the crash also hits the CPU-only preload path, so --disable-gpu and the acceleration setting make no difference.

Fix

Cap graphOptimizationLevel at "basic" on x64, skipping the Level-3 pass entirely. arm64 keeps ORT's default.

Gating on process.arch === "x64" rather than process.platform === "win32": the crash is architecture-scoped, not OS-scoped, so a win32 gate would leave Intel Mac (#38) and Linux x64 (#37) broken.

Graph optimisation only changes how the math is evaluated, not what it computes — worst case is last-decimal differences in output samples, nothing audible.

Verification

  • Session creation smoke-tested on arm64 at both "basic" and "all": both succeed, init 591ms vs 613ms, so the arm64 path is unaffected and the option costs nothing measurable.
  • x64 verification comes from @Blue4Life90 in Windows 11 (AMD GPU): app initializes then exits ~2s into startup — no window, crashpad not connected #36, who root-caused this and tested the matrix on Windows 11 / AMD: default → crash, "disabled" → OK, "basic" → OK, mem-arena-off / single-thread → still crash. With "basic" the app reaches ONNX session providers: cpuModel preloaded successfully and stays running.

Credit for the root cause and the fix goes to @Blue4Life90, who diagnosed it down to the transformer and verified it on affected hardware.

Possible follow-up

"extended" (Level 2) should also avoid NCHWc — the layout transforms are Level 3, and this ORT version lists 'layout' as a distinct level above 'extended' — which would retain more optimisation than "basic". Nobody has verified that on x86 hardware yet, so this PR ships the tested value.

Separately, this class of failure is invisible by design right now: three users lost days to a crash that writes no log. An early main-process log file (before userData exists) plus crashReporter on Windows would make the next one self-reporting.

🤖 Generated with Claude Code

onnxruntime-node 1.23.2 segfaults inside NchwcTransformer while applying
Level-3 (layout) graph optimisations to model_q8f16.onnx. The crash is a
native abort inside InferenceSession.create, so the JS try/catch never
runs and the process dies ~2-3s into startup with nothing logged and no
crash report — the app just disappears.

NCHWc is x86-only, which is why this reproduces on every x64 platform
(Windows, Linux, Intel Mac) regardless of GPU vendor, and never on Apple
Silicon. It also hits the CPU-only preload path, so --disable-gpu and
acceleration settings make no difference.

Cap graph optimisation at "basic" on x64 to skip the pass entirely.
arm64 keeps ORT's default. Session init on arm64 is unchanged (~600ms
either way).

Fixes #36
Fixes #37
Fixes #38

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julia-kafarska
julia-kafarska merged commit 79779c4 into main Aug 4, 2026
1 check passed
@julia-kafarska
julia-kafarska deleted the fix/x64-onnx-graph-optimization branch August 4, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant