error when selecting file in pi with @
thread '#���`` note: run with RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 3, aborting
fish: Job 1, 'pi' terminated by signal SIGABRT (Abort)
info will be added later
Which version?
[triage-bot] NEEDS INFO:
Panic site is crates/fff-core/src/types.rs:163 in DirItem::write_dir_name, only reachable via directory-search scoring (crates/fff-core/src/score.rs:366). The garbled '#���' and bytes 7..10 indicate last_segment_offset lands inside a multibyte UTF-8 char of the directory path.
To repro need:
- fff version (
:lua print(require('fff').version or 'unknown')or commit/tag installed). - The exact query that triggers it — full text after
@, not just@. - One example directory under your indexed root whose path contains non-ASCII bytes (CJK, accented chars, emoji). Output of
cd <indexed-root> && find . -type d | grep -v '^\./\.git' | LC_ALL=C grep -P '[\x80-\xff]' | headwould be ideal. - OS + filesystem (macOS HFS+/APFS normalizes to NFD which can interact poorly with NFC input).
Honk-Honk 🪿
this is using pi agent @gustav-fff try to run the local pi agent with fff and use different directories with different unicode symbols until you find the reason
[triage-bot] STATUS:
Could not provoke panic locally. No pi agent setup here, exercised the dir-search code path directly with unicode dirs (café/, 日本語/, русский/, ümlaut/, emoji_😀/) — last_segment_offset lands on char boundaries in every case because populates_dirs_files_chunked_storage (crates/fff-core/src/file_picker.rs:1953) computes it via trimmed.rfind(std::path::is_separator).map(|i| i+1) and / is 1-byte ASCII.
Panic message '\0' (bytes 7..10) is suspicious: \0 is 1 byte, but the offending char spans 3 bytes — display escape mismatch suggests the underlying buffer is corrupted (chunk-zero padding leaking past byte_len), not just an offset miscompute. read_to_buf slices &buf[..total] with from_utf8_unchecked — if byte_len got out of sync with the actual stored bytes (e.g. u16 truncation, race with watcher rewrite), you would get exactly this signature: a path that prints as # followed by replacement chars, with offset pointing into padding.
To pin this down need:
- The exact rel path of the directory at fault. Can you reproduce on a minimal repo and share
ls -la <indexed-root>? - fff version / commit. Reporter never answered.
- Is the picker invoked while the FS is being modified (build, git checkout)? Watcher race is the most likely vector.
Without a concrete repro path or version, fix is speculative. Holding.
Honk-Honk 🪿
@hpietukhin can you please provide more information or at least which language you use and which path did you try to search for?
[triage-bot] DIRECTED:
Cannot drive pi here — no provider credentials in this sandbox, pi requires --provider + API key and the ones the user has (Google by default) are not present.
Re-examined the panic signature instead: '\0' (bytes 7..10) of '#���'. Three points to flag:
- The string is 10 bytes:
#(1) + three 3-byte sequences. The�glyphs in the rendered message come from non-ASCII bytes inside an unsafe slice —simd_path::ChunkedString::read_to_bufusescore::str::from_utf8_unchecked(crates/fff-core/src/simd_path.rs:186). The byte at offset 7..10 is reported as'\0': that means an invalid/overlong UTF-8 sequence with leading byte0xE0whose continuation bytes decode under-mask to NUL. Valid UTF-8 input cannot produce this — the index has to contain bytes that were never validated. - Plain unicode dirs (
café,日本語,русский,ümlaut,emoji_😀) cannot produce this signature:last_seginpopulates_dirs_files_chunked_storage(crates/fff-core/src/file_picker.rs:1953) only ever points to the byte after a/, which is always a char boundary on valid UTF-8. - The likely source is
to_string_lossyupstream ofadd_dir_immediatemixing with a path the OS hands back containing invalid bytes (HFS+/legacy mounts, NFS, removable media), OR a query/path fed in via the pi tool boundary that bypasses normalization.add_dir_immediatetakes&strso the invalid bytes had to get smuggled in via a priorfrom_utf8_uncheckedsomewhere — the only such site on this code path isread_to_bufitself, which means a chunk in the arena holds non-UTF-8.
A defensive fix at DirItem::write_dir_name (crates/fff-core/src/types.rs:163) using floor_char_boundary would mask the symptom but hide the real corruption. Want me to put up a defensive PR anyway, or wait until @hpietukhin produces the offending path? My vote is wait — masking it will turn future segfaults into silent truncation.
Honk-Honk 🪿
@dmtrKovalenko I also have a problem finding files via @, I'm running pi in an empty directory.
I had previously used this extension without any problems, https://github.com/ShpetimA/pi-fff, so it might help.
[triage-bot] DIRECTED:
Drove pi locally with pi-fff extension installed; could not provoke the panic.
Setup: pi --provider amazon-bedrock (Opus 4.7) with https://github.com/ShpetimA/pi-fff installed. Test repo with paths covering NFC/NFD diacritics, CJK, Cyrillic, emoji, deeply-nested mixed-script:
café/components/résumé_brûlé.txt
café_NFD/file.txt # NFD-normalized 'café'
日本語ディレクトリ/混合english_日本語_русский.md
русский_язык/подпапка/...
ümlaut_test/...
emoji_😀_dir/sub_📁/...
deep/nest/with/lots/of/levels/接收/中文/文件夹/混合english/日本語.md
naïve_implementation.py
résumé.pdf
Queries fired (all routed through mixedSearch → fuzzy_search_directories → DirItem::write_dir_name, the panic site):
@日本, @接收, @русск, @café, @ümla, @résum, @🇯🇵, @a, plus @日本語.md / @résumé.pdf as direct file mentions, plus the empty-cwd case from @Mauladen.
All returned cleanly. No panic. No '\0' (bytes 7..10). Worth noting: the editor's @ autocompletion in packages/pi-fff/src/index.ts:375 calls mixedSearch, which is exactly the code path that exercises last_segment_offset. So the panic is reachable in principle, just not by any unicode shape I could construct.
Why the existing code is sound on valid UTF-8: populates_dirs_files_chunked_storage (crates/fff-core/src/file_picker.rs:1962-1973) computes last_seg via trim_end_matches(is_separator) then rfind(is_separator).map(|i| i+1). is_separator matches only / (and \ on Windows) — both 1-byte ASCII. So i+1 always lands on a char boundary in any valid UTF-8 input.
Why the panic message is still suspicious: '\0' (bytes 7..10) of '#���'. Bytes 7..10 is a 3-byte span, but the offending char is reported as '\0'. Valid UTF-8 cannot encode NUL as a 3-byte sequence — overlong encodings are rejected by core::str::from_utf8. This signature only emerges when core::str::from_utf8_unchecked is fed raw bytes that aren't valid UTF-8. The unsafe sites on this code path:
crates/fff-core/src/simd_path.rs:153, 186—read_to_buf/read_filename_inlineslice the chunk arena and reinterpret as&str.crates/fff-core/src/file_picker.rs:228, 348, 402—to_string_lossy()is used at scan boundaries; this cannot produce the signature directly (it inserts U+FFFD = 3-byteEF BF BD, which would render correctly).
My current hypothesis: a chunk-arena entry holds non-UTF-8 bytes. Possible source = race between background watcher's add_file_immediate and reader (overflow region). The '#' first byte is too clean to be coincidence — it's a single concrete value, not a partial decode artifact. Smells like a stale chunk index pointing into freed/reused memory rather than a unicode-handling bug.
Cannot fix without a concrete repro path or coredump. Both reporters need to share:
- fff version (
fff --versionor commit/tag). - The full path that crashed — preferably
xxdof the offending directory entry.'#���'printed in the panic is mojibake; the actual bytes are what matter. - Whether the picker was invoked while the FS was being modified (e.g. in a build watcher, git checkout, ongoing index, npm install).
Defensive floor_char_boundary at types.rs:163 would mask but not fix this. Holding for repro.
Honk-Honk 🪿
@gustav-fff unfortunately i wasn't able to find or recover logs. what if file name has space in it? Like "Red Book" eg or backticks
@gustav-fff try more queries weird queries
[triage-bot] DIRECTED:
Ran 70,490 query shapes against two indexed trees (the fff repo itself + a synthetic tree with NFC/NFD diacritics, CJK, Cyrillic, emoji, deeply-nested mixed-script, names with #/@/\/spaces/backticks/Red Book/файл с пробелом/etc). All went through mixedSearch (the @-mention path in packages/pi-fff/src/index.ts:368).
0 panics. 0 errors. No '\0' (bytes 7..10). No reproduction.
Query matrix included every printable ASCII byte as both standalone token and as second token paired with each of: ASCII letters, separators, glob meta (* ? [ ] { }), constraint prefixes (! @ # : \\), type:/status:/g: keys with empty/garbage values, leading/trailing/double slashes, escaped tokens (\\* \\! \\@ \\# \\n), and the literal queries the reporters mentioned (Red Book, @\"Red Book\", Red\\ Book, \` , `, ``\ ``).
What I can rule out from this run:
- Parser-level panic on weird tokens — no constraint shape produced via the public query surface reaches the unsafe slice with corrupt state.
- Spaces/backticks in queries (the @hpietukhin hypothesis) —
extractAtPrefix(packages/pi-fff/src/index.ts:239) only allows@\"...\"or@<no-space>, so@Red Bookwithout quotes never even reaches the finder. With quotes it parses cleanly. - Empty-cwd case from @Mauladen —
mixedSearchon a 0-file index returns{ items: [], total_matched: 0 }cleanly. The screenshot shows a UI-side issue, not the panic from #545. - Plain unicode dirnames —
last_segment_offsetisi+1of an ASCII separator (crates/fff-core/src/file_picker.rs:2007-2011), always lands on a char boundary regardless of multibyte content downstream.
What I still cannot rule out (and what would explain '\0' (bytes 7..10) of '#���'):
- Filesystem returning non-UTF-8 bytes.
FileItem::new_from_walkusesrel.to_string_lossy().into_owned()(crates/fff-core/src/file_picker.rs:367). On an APFS/HFS volume that's clean, this never produces invalid UTF-8 —to_string_lossyinserts U+FFFD (EF BF BD). But on NFS, SMB, FUSE, or removable media with mojibake filenames, the OS can hand back bytes that aren't valid UTF-8 in any encoding. If a watcher event delivers those bytes via a code path that bypassesto_string_lossy, they land in the chunk arena andread_to_buf'sfrom_utf8_unchecked(crates/fff-core/src/simd_path.rs:186) reinterprets them as&str. The'#'first byte + 3 garbled bytes pattern matches:'#'(0x23) + 3-byte sequence whose continuation bytes decode under UTF-8 mask to\0. - u16 overflow on
last_segment_offsetorbyte_len. Both areu16(simd_path.rs:72,74,types.rs:81). A path > 65535 bytes truncates silently. Unlikely on most systems but possible with pathological deep CJK paths (each char = 3 bytes).
@hpietukhin / @Mauladen — without one of:
- a coredump (
ulimit -c unlimitedthen re-run, share the core) RUST_BACKTRACE=1 pi ...output, ORxxdof any directory entry under your indexed root that contains non-ASCII bytes,
this is unfixable from my side. The panic is real but I cannot synthesize input that reaches it.
Recommend two things to the maintainer:
- Add
RUST_BACKTRACE=1capture by default when pi spawns fff, or wire fff's panic hook to dump the path bytes that triggered the panic. Right now the panic message goes through Rust's default formatter which mojibakes the bytes — we never see what's actually in the arena. - Replace
from_utf8_uncheckedinsimd_path.rs:186with a debug-buildfrom_utf8assertion (release stays unchecked for perf). Would catch this at injection time instead of at the slice site.
Holding. No PR — masking the slice with floor_char_boundary would silently truncate what should be a hard error.
Honk-Honk 🪿
closing this issues as I am not able to reproduce the issue