Skip to content

Native crash (SIGTRAP) in fff-scan thread during watcher resubscribe after scan — FileItem::write_absolute_path overflows fixed 1024-byte buffer (macOS arm64) #43356

Closed as not planned

Description

@JustBlazer

Summary

opencode crashes with a native Rust panic in the bundled fff file-indexer during a scan, killing the whole process with no error in opencode.log.

  • opencode: 1.18.18 (latest at time of filing)
  • Platform: macOS 26.5.2, Apple Silicon (arm64)
  • Crash reports: ~/Library/Logs/DiagnosticReports/opencode-2026-08-18-210957.ips and opencode-2026-08-18-222412.ips — two crashes ~75 min apart, byte-identical faulting stack.

Crash signature

EXC_BREAKPOINT / SIGTRAP
faultingThread: 33, thread name: "fff-scan"

fff_search::types::FileItem::write_absolute_path::h6be4aaca40dafd85
fff_search::scan::rescubscribe_watcher_post_scan::hd9b19e5fc8d2229e
fff_search::scan::ScanJob::run::hb82750f8c22d9326
std::sys::backtrace::__rust_begin_short_backtrace
core::ops::function::FnOnce::call_once{{vtable.shim}}
std::sys::thread::Thread::new::thread_start

What was happening

Both crashes occurred during long agentic sessions in a git repo with multiple worktrees (jot-brain, jot-brain-wt119, jot-brain-wtsec). The app log shows the session running a rescan loop and stopping abruptly mid-step with no error line:

...loop session.id=ses_... step=243
[trace/breakpoint trap]  ← process dies here, nothing logged

Root cause hypothesis (from fff source)

The panic is in FileItem::write_absolute_path (fff-core/src/types.rs), which writes base_path + '/' + relative_path into a fixed-size stack buffer:

#[cfg(not(target_os = "windows"))]
pub const PATH_BUF_SIZE: usize = libc::PATH_MAX as usize;   // 1024 on macOS

pub(crate) fn write_absolute_path<'a>(&self, arena, base_path, buf: &'a mut [u8; PATH_BUF_SIZE]) {
    let base_len = base.len();
    buf[..base_len].copy_from_slice(base);          // panics if base_len > 1024
    ...
    buf[base_len] = std::path::MAIN_SEPARATOR as u8; // panics if base_len == 1024
    ...
}

There is no bounds check. During ScanJob::run → rescubscribe_watcher_post_scan (fff-core/src/scan.rs), the watcher is re-subscribed to every indexed directory; any directory path ≥ PATH_BUF_SIZE (1024 on macOS) causes a slice index out of range Rust panic.

Rust panics in the native lib abort the process via an int3 trap → recorded by macOS as EXC_BREAKPOINT/SIGTRAP, and bypass the opencode JS logger, so the app log just ends mid-loop with no error. The two identical .ips files confirm a deterministic trigger rather than two unrelated incidents.

Related

Ask

  • Bounds-check the path write in write_absolute_path (fall back to heap PathBuf when PATH_BUF_SIZE is exceeded).
  • Consider raising PATH_BUF_SIZE / not truncating silently.

Crash reports available on request.

Activity

  1. JustBlazer commented on Aug 19, 2026

    @JustBlazer
    Author

    Attaching the two macOS crash reports (.ips) — both are pre-anonymized by the OS (paths shown as /Users/USER/..., no environment variables or credentials inside). Verified the faulting thread is identical in both:

    EXC_BREAKPOINT / SIGTRAP
    fff-scan thread
      fff_search::types::FileItem::write_absolute_path
      fff_search::scan::rescubscribe_watcher_post_scan
      fff_search::scan::ScanJob::run
    

    Gist: https://gist.github.com/JustBlazer/b48ea77fa1520eaf371cfab6592f8577

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions