Correctness report · NVIDIA/hyperflare-inference #178

Raw Markdown for agents: https://autobot.eidonix.com/p/49a08ebb-e7aa-4d23-9781-818d160c6311.md

Key findings

Verdict: clean — no blocking or should-fix correctness defects at head 43c6ea78. The rebase fixed the two blockers my earlier review raised (the diff edited flare/src/main.rs (not opened), a file main no longer has; and the argued placement inside serve() is unreachable on Windows). The change now does what it claims in the only code path Windows serving uses, and it matches the Unix ordering.


What the diff does, in context

flare-cli/src/main.rs (+7/−6), docs/windows.md (+2/−2).

  1. The early registration inside run() is deleted (it sat where the old branch had it, immediately after the Windows multi-host rejection):
#[cfg(windows)]
if args.rank.is_some() || args.rendezvous.is_some() || !args.hosts.is_empty()
    || args.roce_ring || args.roce_chain
{
    return Err("multi-host serving is not supported on Windows".into());
}
// deleted: SetConsoleCtrlHandler(Some(stop_console), 1)

(flare-cli/src/main.rs:178-186; the deleted block was the #[cfg(windows)] unsafe { … } that followed it.)

  1. A new registration is added in serve_local, after loaded.start() and beside the Unix signal block:
695  let phase = progress.phase("Start server", None);
696  let session = loaded.start().map_err(|failure| failure.message)?;
...
699  #[cfg(unix)] unsafe {
700      libc::signal(libc::SIGINT, stop as *const () as libc::sighandler_t);
701      libc::signal(libc::SIGTERM, stop as *const () as libc::sighandler_t);
702  }
704  #[cfg(windows)] unsafe {
706      // Loading keeps the default Ctrl-C termination; nothing reads STOP before serving.
707      if windows_sys::Win32::System::Console::SetConsoleCtrlHandler(Some(stop_console), 1) == 0 {
708          return Err(std::io::Error::last_os_error().into());
709      }
710  }
711  progress.finish_animation();
712  if let Err(error) = server.start_dashboard() { ... }
715  while !STOP.load(Ordering::Relaxed) && server.wait(Duration::from_millis(250)) {}

(flare-cli/src/main.rs:695-715)

Does Windows always reach this site?

Yes, and I traced each branch rather than assuming it:

So on Windows the process that serves is serve_local via flare-cli/src/main.rs:597 (return serve_local(owner, config, progress);), and the registration at 704-710 always executes before the serving loop.

Is the ordering right?

Download and model load now run with no handler and therefore the default console termination — exactly the Unix situation before SIGINT/SIGTERM are installed at 699-702. That is the fix: previously stop_console returned 1 ("handled") for CTRL_C_EVENT | CTRL_BREAK_EVENT (flare-cli/src/main.rs:737-746) and suppressed the default termination, while on Windows nothing read STOP before the serving loop.

Server::start is also inside the default-termination window now. Note this is deliberate and is the safer direction: Server::start blocks on worker readiness (helios/src/server.rs:417) while startup tuning graphs run under a 120 s-per-graph completion deadline and a 120 s drain deadline, with no STOP check (helios/src/execution/transport.rs:739-784). Registering before the start would have re-created the reported symptom for minutes at a time.

Error handling and lifetimes at the new site

If SetConsoleCtrlHandler returns 0 (:707), the function returns Err(last_os_error()) while session: ServingSession is still owned. ServingSession::drop calls close() (helios/src/server/session.rs:104-108), which sets owner.drained = shutdown.drained (:96-100); DrainGuard::drop releases the model only on confirmed drain and otherwise mem::forgets it (:125-133). So the failure path neither leaks badly nor frees CUDA storage under live work. The description's claim that a registration failure "returns before replay begins, instead of dropping the package owner without a confirmed drain" holds for the new site: startup replay is driven by the serving loop that starts after this point.

Minor ordering consequence: on that error return, progress.finish_animation() (:711) and start_dashboard() (:712) are skipped, so a spinner may be left on screen. Cosmetic only.

Docs

docs/windows.md:141-142 now reads: "Ctrl-C and Ctrl-Break end loading immediately and drain native work before releasing CUDA resources once serving has started." That is accurate for 704-710: default termination before registration, handler-driven drain after. It also correctly narrows the old unconditional promise.


Findings

Nit 1 — a second Ctrl-C cannot force exit during the drain (flare-cli/src/main.rs:738-746)

737  #[cfg(windows)]
738  unsafe extern "system" fn stop_console(event: u32) -> i32 {
739      use windows_sys::Win32::System::Console::{CTRL_BREAK_EVENT, CTRL_C_EVENT};
740      if matches!(event, CTRL_C_EVENT | CTRL_BREAK_EVENT) {
741          STOP.store(true, Ordering::Relaxed);
742          1
743      } else { 0 }
746  }

Once the loop at :715 exits, the process runs session.close() (:719), which joins HTTP and model workers and waits for native replay to drain (helios/src/server.rs:524-560). Every subsequent Ctrl-C still returns 1, so the default handler never runs and the user cannot terminate a slow or stuck drain except by force. This is pre-existing (Unix stop, flare-cli/src/main.rs:52-55, also only sets STOP), so it is not a regression introduced here; I record it because this PR is the one that changes Ctrl-C semantics on Windows. One-line fix, and it is exactly the fallback the earlier review suggested:

if STOP.swap(true, Ordering::Relaxed) { 0 } else { 1 }

Returning 0 lets the next handler — the default one — terminate the process.

Nit 2 — the PR description describes the pre-rebase design

The description states "Register the handler immediately before Server::start" and "A Ctrl-C during Server::start sets STOP, so the serving loop exits at once and native replay drains before CUDA resources are released." At this head both statements are false: the registration is at :704-710, after loaded.start() at :696. In practice a Ctrl-C during Server::start (startup tuning, up to 120 s per graph, helios/src/execution/transport.rs:739-784) now terminates the process without the graceful path. That is the right choice — it restores default termination instead of swallowing the key — but the consequence worth stating is that an abrupt Ctrl-C during tuning bypasses GraphExecutor's record-and-drain-or-abort protocol (helios/src/execution/transport.rs:767-783) and lets process exit tear down the CUDA context. Unix behaves identically today, so this is parity rather than a defect; the description should be rewritten to say loading (including Server::start) keeps the default termination and only the serving loop drains.

(Author's comment of 2026-11-28 states the description was updated; the text I was given still carries the old wording, so at minimum it needs re-checking before merge.)

Nit 3 — no terminal restore on the new abrupt-exit paths

Ctrl-C during download or load now terminates without running any epilogue, so progress's ANSI/cursor state (progress.finish_animation() at :711 never runs) can be left on the console. Cosmetic; the same file already accepts this for its other early errors. Precedent for restoring it on a signal path is heliopause/src/processes_windows.rs:16-27 (not opened).


Evidence gap (should be stated in the PR, not a code defect)

At 43c6ea78 there is no Windows compile and no Windows run. Both are resolvable and one is already partly covered:


Verified non-issues (checked, no finding)

Open questions

  1. Whether a second Ctrl-C should be allowed to force exit during the drain (Nit 1) — needs a maintainer decision on policy, since Unix has the same gap and fixing only Windows would diverge the platforms further.
  2. Whether the 120 s-per-graph tuning window inside Server::start is acceptable to leave uninterruptible on Windows (Nit 2). The alternative — a handler that sets STOP and also aborts tuning — would require STOP checks in helios/src/execution/transport.rs, i.e. a helios change outside this PR's scope.
  3. The Windows compile result and one live Ctrl-C session: only CI and a Windows machine can settle these; nothing in the code blocks on them.