Skip to content

early_ctrlc / doctor subcommands bypass guard-flush via process::exit, same root cause as #6693 #6696

Description

@bug-ops

Description

Follow-up from PR #6695 (#6693). While fixing the SIGTERM-flush gap for log_guard/chrome_guard, the review chain (critic + reviewer) found that Ctrl-C / SIGINT handling has the same root-cause gap and is out of scope for #6693, but should be tracked separately.

early_ctrlc (src/runner.rs:1650-1654) calls std::process::exit(130) directly when Ctrl-C is pressed. process::exit runs no destructors at all, so it bypasses TracingGuards::drop (and therefore both the log_guard and chrome_guard take-once-cell flush logic added in #6683/#6692/#6693) entirely — not just the theoretical SIGTERM race window, but every single Ctrl-C during the period early_ctrlc is live (from init_tracing at src/runner.rs:867 until early_ctrlc.abort() at src/runner.rs:4040 — i.e. essentially all of bootstrap and dispatch).

On non-Unix platforms, spawn_sigterm_flush_task is a no-op (SIGTERM handling is Unix-only), so Ctrl-C's process::exit path is the only termination route available — meaning any equivalent of the #6693 truncation bug is not fixed at all on non-Unix.

Also flagged: the doctor subcommands (src/runner.rs:1140, 1156, 1172) call process::exit directly in similar fashion and share the same root cause.

Expected Behavior

Determine whether early_ctrlc and the doctor subcommands' process::exit calls should instead route through the same take-once-cell flush mechanism (e.g. have the Ctrl-C handler flush the guard cells before exiting, mirroring spawn_sigterm_flush_task's approach for SIGTERM), or whether the risk/cost tradeoff differs enough (Ctrl-C is an interactive, user-initiated action rather than an external supervisor's pkill, so data loss expectations may differ) to leave as-is with just accurate documentation.

Reproduction Steps

  1. Run a live session with logging enabled (RUST_LOG=debug, file output configured) and a burst of log writes in flight.
  2. Press Ctrl-C during that burst (or during init_tracing through early_ctrlc.abort()).
  3. Inspect the resulting log file / local Chrome trace file for truncation or a missing tail.

Environment

  • Version: unreleased (main, as of 2026-07-28)
  • Relevant code: src/runner.rs (early_ctrlc, doctor subcommand process::exit call sites), src/tracing_init.rs (TracingGuards::drop, spawn_sigterm_flush_task)

Metadata

Metadata

Assignees

Labels

P3Research — medium-high complexitybugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions