D3D12-PLAYER-CONTEXT-NO-STDERR-PANIC: never panic printing to stderr in player_context::say #2840
Closed
leonida/mandy
bobcatchris wants to merge 3 commits from
github-pr/2840 into main
pull from: github-pr/2840
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2840
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/2840"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
Please reopen this pull request to perform a merge.
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.I isolated
sayon native Windows 11 with Rust 1.98.1/MSVC. I copied the function verbatim from main640b0d0dfand fromaf4aeaa5emerged into it (tree68d6eae14). The same standalone harness called it three times from a named thread. The parent closed the stderr pipe's read end before releasing the child, and a fallible control write independently got Windows error 232 every time.failed printing to stderrand returned a failed joinThis 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 files
Verdict: PASS. The premise is right — I measured that
eprintln!really does panic when writing to stderr fails — and the replacement does not.Head
af4aeaa5, base the currentmain88a9f133, merge base86c30fce, 1 commit, 1 file, +4/−1:d3d12/apps/leonida/src/player_context.rs.1. The change
2. The premise, measured
eprintln!does panic when the write fails. I wrote a program that writes to stderr and pointed stderr at/dev/full, which fails every write withENOSPC:and the same program's direct write reports the failure instead of panicking:
One methodological note, because my first attempt was wrong: closing stderr (
exec 2>&-, oros.close(2)beforeexecv) does not make the write fail — Rust's standard library opens/dev/nullfor a file descriptor 0, 1 or 2 that is closed at startup, so the write succeeds. The first version of this test therefore showed "no panic" for both paths, which said nothing./dev/fullis what actually produces a failing write.3. The new code compiles and does not panic
writeln!needsstd::io::Writein scope, and the file already has it:use std::io::Write as _;atplayer_context.rs:28. The macro's third argument form (writeln!(std::io::stderr(), …)) needs no further import.In the same program, the
writeln!form returnsErrand thelet _ =discards it, so the message is lost and nothing panics — the behaviour the pull request wants.4. The thread it happens on
The pull request's comment says the message goes to "this thread, which has no stop signal". That is right:
player_context.rs:582-585starts the thread and drops theJoinHandle:run()(:438) isloop { std::thread::sleep(TICK); … }with no exit condition and no stop flag anywhere in the module.So a panic in
say()would end that detached thread and the player-context feature would stop silently, with the panic message printed by the default hook. It would not take the process down — unlike the case in #2858, where the same kind of overflow sits inside the exception handler. The pull request does not claim it would; it says a player-context message "must never panic", which is the right standard for a message printed from a background thread.5. What I did not check
apps/leonidadepends onleonida-loader,leonida-hleandleonida-gpu, none of which build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), socargo test -p leonidadoes not run here. The four-line change is inplayer_context.rsand I checked it by reading; thesay()function itself I reproduced in a standalone program, which is where the measurement in §2 comes from.std::io::stderr()on Windows writes to the console handle or to the redirected handle, and a failing write there would produce the sameErr; I did not check it there.say/println!calls in the module.install()and the dump path useprintln!(stdout), which panics the same way on a failing write; this pull request does not touch them. They are on the calling thread rather than the background one, and a panic there would unwind out ofinstall()into the caller — which may be a separate question, but it is not this pull request's.AI-assisted: MiniMax M3.1 Flash.
I ran a Win64 closed-stderr subprocess check through the actual player_context::say at af4aeaa5 + 0ff8a532f, 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
4db84a195(after mergingmain, no rebase/force-push):say_does_not_panic_when_stderr_pipe_is_closedthat closes the stderr pipe read end before callingsay()and asserts the child runs and exits cleanly (red if reverted toeprintln!).say()'s doc comment that failed writes are silently dropped, and narrowed the PR title toplayer_context::say(keepinggame_actions::log/run.rsout of scope for a single-topic PR).cargo test --locked -p leonida player_context::tests(9 passed, 0 failed),tools/d3d12_switches.py --check, andpython -I scripts/check_no_game_data.py(clean).AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass).
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
RUN (in game, batch of six render-path pull requests), each head merged with
git merge --no-ffonto main83046a713, in one build: #293345e0aae53, #28314375de941, #28404db84a195, #28873be77fdeb, #28555e4cd9bcb, #29959e1e95930. RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.For reference, the same machine and route rendered 13.3 to 15.2 fps today on main with single pull requests and 14.9 with the first batch; no compile ran beside the game this time. These fps are a check that nothing fell over, not a measurement of a gain.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; free system memory was low (median 1.3 GB); arrival in the world was driven by keys and not checked on pictures.
AI-assisted (Claude Code).
Verification triage of #2840
Head
4db84a195is already verified: MoonEyes' in-game batch run on this exact head (2026-12-02 15:53). CI passes (6/6) and the PR merges cleanly. No new run here (Windows-only). Verdict: ready (already verified on this head).AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
VERIFY-2840 — Windows nativo: el control reproduce el pánico que el cambio evita
Un fichero, 46 líneas, once días abierto:
Control (sintético): volver a
eprintln!— la línea que el cambio sustituye:Muerde exactamente el caso que el cambio describe, y el test es de los que hay que mirar dos veces porque no comprueba un valor: abre un hijo con stderr cerrado (
PLAYER_CONTEXT_CLOSED_STDERR_TEST) y exige que no haya pánico. Uneprintln!con el pipe cerrado hacepanic!en Rust, y en este hilo —sin señal de parada— eso mata el proceso en el apagado.Y el comentario del cambio lo dice mejor de lo que yo podría:
Eso es un
let _ = writeln!(…): tirar elResulta propósito, con la razón escrita al lado. Y es la clase de cambio que no se puede aprobar leyendo el diff sin el comentario — ellet _parece descuido y es la corrección.Lo que no probé: el apagado real del juego con la consola cerrada, que es el escenario de verdad; el test lo fabrica con un hijo, que es la versión que se puede correr en CI.
Written with an AI assistant.
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2840, #2833, #2832 and #2831 merged into main
09273248c; this PR tested at its current head4db84a195. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, screen kept on.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
Closing as superseded: main replaced
say()inplayer_context.rswithnote()throughsay_err!(out.rs), which already ignores a failed write to stderr. The fix is covered on main, and the test here calls asaythat no longer exists.Closed by Moon's agent during PR triage, on Moon's written authorization, after a separate reviewer agent checked it against main
0036195a7. A new pull request rebased on current main is welcome.