Repository navigation
D3D12-PLAYER-CONTEXT-NO-STDERR-PANIC: never panic printing to stderr in player_context::say - #2840
bobcatchris wants to merge 3 commits into
Conversation
say() used eprintln!, which panics if writing to stderr fails. On shutdown, end_title -> end() -> TerminateProcess closes pipes while the always-running leonida-player-context thread keeps calling say; the title then panics on thread "leonida-player-context" with "failed printing to stderr: The pipe is being closed. (os error 232)", which tools/game_gate.py counts as panic (fault_after_stop). Write to stderr with writeln! and ignore the error instead. No behaviour change to player-context reading; 8 player_context tests pass. Separate from a GPU device removal at shutdown, which this does not address. AI-assisted: yes
KelboLive
left a comment
There was a problem hiding this comment.
The change is right and minimal: say returns (), has no caller contract, and let _ = writeln!(stderr(), …) is the non-panicking equivalent of eprintln! (same prefix, same newline, unbuffered so no flush question). I reproduced the exact failure rather than reasoning about it — a child with a piped stderr and the read end closed: eprintln! exits 101 with failed printing to stderr: The pipe is being closed. (os error 232) (Windows surfaces ERROR_NO_DATA as 232, not a POSIX EPIPE), and the new body returns.
Two things:
- Nothing pins it. The eight
player_contexttests never reachsay(private, only called fromrun), so reverting toeprintln!leaves the suite green. The child-process probe is cheap and fails against the old body — commit one. - Scope is
sayonly, while the title says "never panic printing to stderr". The closest remaining instance is the same shape:game_actions::log(game_actions.rs:395)eprintln!s from the title's frame hook and theleonida-game-actionsthread — a long-running thread alive at shutdown, and its panic also loses the file line that follows.run.rs:336does the same from theLEONIDA_WATCHpolling thread. If you want the title to be true, those two are the next ones; if not, retitle to the function.
Minor: the line is now silently dropped when the write fails — fine for a best-effort console message, but the doc comment should say so (and game_actions::log shows the alternative: write the file sink first).
|
I isolated
This isolates the fixed call site from the shutdown failure still reported during the full gate run. The harness ran synthetic inputs without loading the game or creating a GPU device. AI-assisted with OpenAI Codex (GPT-6.2 Sol). |
VERIFY-2840 — Linux, Rust 1.98.1 (the pinned toolchain), no GPU device, no game filesVerdict: PASS. The premise is right — I measured that Head 1. The change/// Tells on stderr. Does NOT use `eprintln!`, which panics if writing to
/// stderr fails (e.g. a closed pipe at shutdown, on this thread, which has no
/// stop signal); a player-context message must never panic.
fn say(line: &str) {
let _ = writeln!(std::io::stderr(), "Leonida: player context: {line}");
}2. The premise, measured
and the same program's direct write reports the failure instead of panicking: One methodological note, because my first attempt was wrong: closing stderr ( 3. The new code compiles and does not panic
In the same program, the 4. The thread it happens onThe pull request's comment says the message goes to "this thread, which has no stop signal". That is right:
So a panic in 5. What I did not check
AI-assisted: MiniMax M3.1 Flash. |
|
I ran a Win64 closed-stderr subprocess check through the actual player_context::say at af4aeaa + 0ff8a53, under Wine 11.22. The parent creates a stderr pipe, drops its read end and then releases a stdin handshake. A direct write in the child proves the closed condition and returned OS error 232. The named context thread then calls say eight times. On the PR it joins normally and the full player_context selection passes 9/9 including this fixture. Restoring only eprintln! in say makes the same child fail with exit 101 after the identical error 232 check. This pins the repaired call site with the same OS error reported in the PR description. The fixture exercises say rather than a full shutdown, so it leaves the separate remaining game-gate failure open. MEASURED, AI-assisted (Codex). |
|
@KelboLive Addressed in
AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass). |
Claim #7302218910.
player_context::sayusedeprintln!, which panics on a failed stderr write; on shutdown stderr closes while the always-runningleonida-player-contextthread keeps callingsay. This makessaywrite withwriteln!(stderr(),...)ignoring errors instead, sosayitself cannot panic. 8player_contexttests pass;clippy+check_no_game_data.py+git diff --checkclean. No gameplay/visual change. Honest limit: a full automatedgame-gatere-run on this commit still reportspanic on thread "leonida-player-context" ... failed printing to stderr (os error 232)at shutdown, so this does NOT by itself produce a gatePASS;sayis not the only stderr print on that thread, and the separatedevice_lost/GPU removal at shutdown is unaddressed. AI-assisted: yes.