Skip to content

fix: guard llama.cpp backend init against SIGILL on x86_64 CPUs without FMA/AVX2 - #10105

Merged
jbg merged 3 commits into
aaif-goose:mainfrom
mvanhorn:fix/10073-guard-llamacpp-fma
Jul 11, 2026
Merged

fix: guard llama.cpp backend init against SIGILL on x86_64 CPUs without FMA/AVX2#10105
jbg merged 3 commits into
aaif-goose:mainfrom
mvanhorn:fix/10073-guard-llamacpp-fma

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

On Linux x86_64, goosed aborts with SIGILL on older Intel CPUs that lack FMA (the reporter's Ivy Bridge i5-3230M has AVX + F16C but no FMA/AVX2). The faulting instruction is vfmadd213ss inside ggml_cpu_init, which the bundled llama.cpp (ggml) CPU backend runs unconditionally when LlamaBackend::init() is called from LlamaCppBackend::new(). Because the illegal instruction takes down the whole backend process, the Desktop frontend then loses every backend-dependent feature (Skills, Apps, session history, ACP websocket).

This adds an x86_64 CPU capability precheck that runs before LlamaBackend::init(). When a required instruction set is missing, it returns a clear, actionable error naming the missing features instead of letting ggml execute an illegal instruction, so local inference is cleanly disabled and the rest of the backend stays alive.

  • check_cpu_supports_local_inference() is gated by #[cfg(target_arch = "x86_64")] and uses std::arch::is_x86_feature_detected! to check the instruction sets the bundled ggml CPU build relies on: FMA, AVX2, F16C, BMI2, and SSE4.2.
  • On non-x86_64 targets (ARM, macOS metal) it compiles to an unconditional Ok(()), leaving those paths untouched.
  • The error message names every missing instruction set so users get an actionable diagnostic.

Testing

cargo test -p goose --features local-inference --lib -- providers::local_inference::llamacpp (the two added unit tests pass):

  • local_inference_cpu_support_check_accepts_current_host derives its expectation from the host's detected features, so it asserts Ok on a supported host and Err on an x86_64 host missing the required sets (the exact environment this fix handles) rather than spuriously panicking there.
  • local_inference_cpu_support_error_names_missing_instruction_sets checks the error message names the missing sets.

Also verified with cargo fmt --check and cargo clippy -p goose --features local-inference -- -D warnings.

Related Issues

Closes #10073

Screenshots/Demos (for UX changes)

N/A. This is a backend change to local inference initialization with no UI surface.

@jbg
jbg force-pushed the fix/10073-guard-llamacpp-fma branch from 9f3caa7 to ae4adc8 Compare July 9, 2026 16:06

@jbg jbg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up I'll look into building llama.cpp with wider CPU support; it already has runtime feature detection so we should be able to support local inference on CPUs without FMA/AVX2. This fix is solid in the meantime though.

@jbg
jbg added this pull request to the merge queue Jul 11, 2026
Merged via the queue into aaif-goose:main with commit 1774b3a Jul 11, 2026
29 of 31 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Thanks for merging, @jbg - guarding llama.cpp init against SIGILL keeps older x86_64 CPUs from hard-crashing.

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.

Linux x86_64 v1.39.0 goosed crashes with SIGILL on older Intel CPUs without FMA, causing Desktop backend disconnects

4 participants