fix(log): create log file when arming SIGSEGV handler fd - #648
Merged
Merged
Conversation
sigsegv::set_log_fd() runs before init_tracing opens/creates the writer file. Its previous OpenOptions used append(true) with no create(true), so on the first-ever session the file did not yet exist, the open failed silently, and LOG_FD stayed -1. When a segfault later fired the banner was written to fd 2 only; nvim discards stderr, and nothing ever hit the log — leaving users with only the terminal banner and no attachable crash section. Refs #641.
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.
Refs #641
Root cause
sigsegv::set_log_fd()(crates/fff-core/src/log.rs:38) opens the logfile with
.append(true).open(path)— nocreate(true). It runs atlog.rs:225, beforeinit_tracingopens/creates the writer fileat
log.rs:237. On the first-ever nvim session for a given user thelog file does not yet exist, so the open fails silently,
LOG_FDstays-1, and when a segfault later fires the banner is written to fd 2only via:
Neovim discards stderr on exit-to-shell, so the user sees the terminal
banner but the log file never contains
=== CRASH SIGSEGV (fff) ===.This is exactly the "the banner is not in my log" complaint in #641.
Once the writer file exists (post-first-session),
set_log_fdsucceedsand the banner does land in the log — which explains why the same crash
can be logged for some users but never for others.
Fix
Add
.create(true)to theset_log_fdopen. Now the fd is armed evenon first launch, and the SIGSEGV path writes the banner into the file
alongside stderr.
Steps to reproduce
Pre-fix, on a machine with no existing fff log dir:
Post-fix: same reproduction,
grep 'CRASH SIGSEGV'finds the banner inthe log file on the very first session, matching the guidance in the
banner itself ("Please file the bug ... with this banner attached").
How verified
cargo check -p fff-search— clean.OpenOptions::new().append(true).open(nonexistent)returnsErrwhile
.create(true).append(true).open(nonexistent)succeeds — thisis the exact silent-fail that was hiding the banner.
Notes
that still requires an attachable crash section from the log or a
gdb backtrace, per [Bug]: neovim plugin crashes neovim when opening a file #641. This PR makes the crash section actually
reachable so future reports carry the frames.
Automated triage via Gustav. Honk-Honk 🪿