From 36a340985ae7e5ec52ec1def4a2885ba49c045cb Mon Sep 17 00:00:00 2001 From: gustav-fff <286169375+gustav-fff@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:13:53 -0700 Subject: [PATCH] fix(log): create log file when arming SIGSEGV handler fd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/fff-core/src/log.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/fff-core/src/log.rs b/crates/fff-core/src/log.rs index 13d3cc452..1e586480c 100644 --- a/crates/fff-core/src/log.rs +++ b/crates/fff-core/src/log.rs @@ -34,8 +34,15 @@ mod sigsegv { static LOG_FD: AtomicI32 = AtomicI32::new(-1); + // Must `create(true)` — this runs before init_tracing opens/creates the + // writer file, so an append-only open on a non-existent path silently + // fails, LOG_FD stays -1, and the SIGSEGV banner never reaches the log. pub fn set_log_fd(path: &Path) { - if let Ok(file) = std::fs::OpenOptions::new().append(true).open(path) { + if let Ok(file) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(path) + { let prev = LOG_FD.swap(file.into_raw_fd(), Ordering::Relaxed); if prev >= 0 { unsafe { libc::close(prev) };