Repository navigation
Description
Summary
The app crashes with SIGABRT on a tokio-rt-worker thread when computing embeddings after importing documents into a fresh database. This only occurs in release builds — debug builds work fine.
Reproducible: Yes — fresh database → import docs → crash when embeddings start (~1-2 minutes after launch).
Crash Report
Process: nodespace-app
Exception Type: EXC_CRASH (SIGABRT)
Triggered by Thread: tokio-rt-worker
Termination Reason: Namespace SIGNAL, Code 6, Abort trap: 6
Application Specific Information: abort() called
Platform: ARM-64 (Apple Silicon), macOS 26.3.1
No useful stack trace — release builds have `strip = true`.
Root Cause Analysis
Primary: Unsafe unwrap on Metal context creation
File: `packages/nlp-engine/src/embedding.rs:291`
```rust
Ok(self.context.as_mut().unwrap())
```
If Metal context creation fails silently on ARM64, this unwrap panics on a tokio worker thread → SIGABRT.
Contributing: Unsafe transmute of context lifetime
File: `packages/nlp-engine/src/embedding.rs:276-281`
```rust
// SAFETY: We're extending the lifetime of the context to 'static.
let ctx: LlamaContext<'static> = unsafe { std::mem::transmute(ctx) };
self.context = Some(ctx);
```
With aggressive LTO + opt-level 3, the compiler may reorder operations around this transmute.
Contributing: Aggressive release optimizations
File: `Cargo.toml:35-40`
```toml
[profile.release]
panic = "unwind"
codegen-units = 1
lto = true
opt-level = 3
strip = true
```
LTO + opt-level 3 + codegen-units 1 can trigger edge cases in llama.cpp Metal kernel compilation on ARM64.
Contributing: Immediate processor wake after init
File: `packages/desktop-app/src-tauri/src/commands/db.rs:104-109`
```rust
processor.wake(); // <-- IMMEDIATE WAKE after init
```
During fresh import, nodes are created and marked stale. `processor.wake()` fires immediately, spawning embedding tasks while imports may still be in flight.
Proposed Fixes (in priority order)
- Replace unwrap with proper error handling in `embedding.rs:291` — return an error instead of panicking
- Add tokio panic hook to log context before abort on worker threads
- Delay embedding wake — wait for import to complete before waking the processor
- Test with reduced optimization — try `opt-level = 2` or `lto = "thin"` for the nlp-engine crate
- Remove strip = true temporarily to get useful crash stack traces
Steps to Reproduce
- Build release: `bunx tauri build --target aarch64-apple-darwin`
- Install the .dmg
- Launch app with fresh/empty database
- Import documentation via MCP or import script
- App crashes ~1-2 minutes in when embeddings processing starts
Environment
- macOS 26.3.1, Apple Silicon (Mac16,8)
- NodeSpace v0.1.5
- Rust release profile: opt-level=3, lto=true, strip=true
Activity
malibio commentedon Mar 20, 2026
Investigation Update
Tested local release builds to isolate the cause:
Conclusion: Not a Rust version issue. The crash is specific to the GitHub Actions
macos-latestrunner environment — likely differences in macOS version, Metal GPU drivers, or the runner's hardware/virtualization layer.Both local release builds processed the same stale embeddings queue that crashed the GitHub-built binary without issues.
Next steps:
RUST_BACKTRACE=1to the GitHub build environment to capture more info on next crashmacos-14ormacos-15runner instead ofmacos-latestto see if a specific runner version is the issuechore: enable crash diagnostics for release builds (#990)
malibio commentedon Mar 20, 2026
Definitive Root Cause Found
With
strip=false, the crash trace is now clear:The crash is a tensor shape assertion in ggml's
ggml_mul_matduringbuild_pooling→build_graph→ context constructor. This is inside llama.cpp's C code — not our Rust code.Additionally, Thread 15 shows
__ggml_metal_rsets_init_block_invokerunning concurrently — Metal resource initialization racing with graph construction.Why GitHub-only: The GitHub Actions
macos-latestrunner is a VM. Its Metal implementation differs from real Apple Silicon hardware — either missing Metal GPU entirely or providing a software Metal implementation that causes ggml's pooling graph to fail a matrix dimension assertion.Local builds work because they run on real Apple Silicon with proper Metal hardware.
Current llama-cpp-2 version: 0.1.132
Fix options:
n_gpu_layers = 0when Metal is unavailable — detect VM/headless and fall back to CPUabort(), not a Rust panicfix: bump MACOSX_DEPLOYMENT_TARGET to 14.0 for Metal ggml compatibili…
fix: commit Cargo.lock for reproducible builds (#990)
fix: pin llama-cpp-2 to 0.1.132 — v0.1.139 has ggml_mul_mat regression (
chore: restore strip=true and remove RUST_BACKTRACE now that #990 is …
malibio commentedon Apr 5, 2026
Fixed across multiple commits: pinned llama-cpp-2 to 0.1.132 (v0.1.139 had ggml_mul_mat regression), bumped MACOSX_DEPLOYMENT_TARGET to 14.0 for Metal ggml compatibility, committed Cargo.lock for reproducible builds, and restored strip=true after diagnosis.
chore: enable crash diagnostics for release builds (#990)
fix: bump MACOSX_DEPLOYMENT_TARGET to 14.0 for Metal ggml compatibili…
fix: commit Cargo.lock for reproducible builds (#990)
fix: pin llama-cpp-2 to 0.1.132 — v0.1.139 has ggml_mul_mat regression (
chore: restore strip=true and remove RUST_BACKTRACE now that #990 is …
Count bare #NNNN issue references in the code-reference check (closes #…
Count bare #NNNN issue references in the code-reference check (closes #…