Skip to content

[Bug] macOS Intel: OpenCode exits with SIGILL in onnxruntime::Environment destructor after local embedding #225

Description

@tlerbao

Summary

After local embeddings became functional on an Intel Mac with opencode-mem@2.22.2, OpenCode consistently crashes during normal /exit. The memory add/search operations succeed; the crash happens later while macOS is finalizing ONNX Runtime's global environment.

The same OpenCode setup did not show this exit crash before enabling opencode-mem local embeddings.

Environment

  • macOS 13.3 (22E252), Intel x86_64
  • OpenCode 1.18.9
  • Embedded Bun 1.3.14 (0d9b296a)
  • Node.js v22.19.0
  • opencode-mem 2.22.2
  • onnxruntime-node 1.22.0
  • Local model: Xenova/nomic-embed-text-v1

Steps to reproduce

  1. Configure opencode-mem@2.22.2 with the default local embedding model.
  2. Start OpenCode and invoke memory add followed by memory search.
  3. Confirm both operations succeed.
  4. Exit normally with /exit.

Actual behavior

The session exits its normal loop and prints the session resume information, then Bun crashes:

panic(main thread): A C++ exception occurred
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
[1] illegal hardware instruction  opencode

Bun report from one occurrence:

https://bun.report/1.3.14/ma10d9b296m5nQuhooCw57luDgi2nuD________uhpwVk1w2bkhmylBkz5iI2rowvD2opk4Culqk4Cyq/59C4wn/H_A0eNpzVHDW1lZIrUhOLSjJzM9TyE9OLi0qSk0BAF13CGE

This reproduced three times. The corresponding macOS DiagnosticReports all show the same main-thread teardown stack:

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Termination Reason: Illegal instruction: 4
Crashed Thread: 0, com.apple.main-thread

std::__terminate
std::terminate
onnxruntime::Environment::~Environment()
OrtEnv::Release
OrtApis::ReleaseEnv
std::unique_ptr<Ort::Env>::~unique_ptr
__cxa_finalize_ranges
exit

There is no JS exception immediately before the crash. OpenCode logs show the session loop exiting normally.

Expected behavior

OpenCode should exit normally after using local memory embeddings.

Isolation evidence

Related upstream issues

This appears to be a Bun 1.3.14 + in-process onnxruntime-node teardown failure, with opencode-mem acting as the trigger by loading ONNX into OpenCode's embedded Bun host. A remote/sidecar embedding backend would avoid the native module in the host process, but no remote embedding endpoint is available in this environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions