fix(nvim): refuse fs-root/home index at Lua level before FFI (#745) - #748
Merged
Conversation
Opening nvim at `/` with lazy=false crashed the whole neovim process on CI-cross-compiled aarch64 .so binaries: the init_file_picker FFI call SIGSEGVs instead of returning Error::FilesystemRoot cleanly. A SIGSEGV is a hardware signal that the pcall around init_file_picker cannot catch. Mirror the Rust refusal (file_picker.rs:862) in Lua and bail before crossing the FFI boundary, so the crashing path is never reached. Same guard added to change_indexing_directory for the :cd-into-root case. Honors enable_fs_root_scanning / enable_home_dir_scanning overrides.
Owner
|
@gustav-fff remove all the comments you wrote (they are slop) and leave the only one |
Collaborator
Author
|
[triage-bot] DIRECTED: Done. Honk-Honk 🪿 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #745
Root cause
Opening nvim at
/withlazy=falsekills the entire neovim process on the CI-cross-compiled aarch64.so. The Rust side is supposed to returnError::FilesystemRootcleanly (crates/fff-core/src/file_picker.rs:862), and a nativecargo build --releasedoes exactly that. But the published aarch64 binary SIGSEGVs at theinit_file_pickerFFI call instead of returning the error — as the reporter confirmed (exit=139, core dump, corrupt stack; native build exits 0).A SIGSEGV is a hardware signal. The
pcallaroundinit_file_picker(lua/fff/core.lua) cannot catch it, so it propagates and takes neovim down. The SIGSEGV banner in the crash buffer comes from fff's own signal handler (crates/fff-core/src/log.rs:54).The underlying aarch64 codegen/segfault is a separate issue for @dmtrKovalenko. This PR is the Lua-level workaround requested in #745 (comment).
Fix
Mirror the Rust root/home refusal in Lua and bail before crossing the FFI boundary, so the crashing path is never reached:
ensure_initializedrefuses whenbase_pathis a filesystem root (/,C:) or$HOMEwith the matching scan flag disabled, notifies at WARN, and returns without calling into Rust.change_indexing_directorygets the same guard for the:cd /-after-init case.enable_fs_root_scanning/enable_home_dir_scanningoverrides — no new config, no behavior change when scanning is allowed.~40 LOC,
lua/fff/core.luaonly.Steps to reproduce
On pre-fix
main, published aarch64 build (or any build where the FFI segfaults):Expected: clean refusal, neovim survives. Actual: SIGSEGV, exit 139, core dump.
How verified
Logic of the guard validated in isolation under headless nvim (the module itself needs the compiled backend to load):
stylua --check lua/fff/core.luapasses.Post-fix,
ensure_initializedat/returns without touching the FFI, so neovim no longer crashes regardless of the aarch64 codegen bug.Automated triage via Gustav. Honk-Honk 🪿