D3D12-LOADER-CRASH-NO-STDERR-PANIC: never panic on closed stderr in crash reporting #2946
Open
github-bot
wants to merge 1 commit from
github-bot/gh-2946 into main
AGit
pull from: github-bot/gh-2946
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
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
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2946
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2946"
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?
@bobcatchris on GitHub · 2026-12-01 20:35 UTC · original
bobcatchris:fix/d3d12-loader-crash-no-stderr-panic→main· +105 −8 · 1 files · 1 commits · openSummary
Claimed in the coordination issue as:
D3D12-LOADER-CRASH-NO-STDERR-PANIC(#2570).Prevents
d3d12/crates/leonida-loader/src/crash.rsfrom panicking on a closed/failing stderr pipe during crash reporting:log_crash: writesappend_to_log(&text)first and writes to stderr withlet _ = write!(std::io::stderr(), "{text}");instead ofeprint!, so a closed stderr pipe never loses thecrashes.logentry.report(called fromextern "system"VEH/SetUnhandledExceptionFilter): replaceseprintln!("{l}"),eprint!("{said}"), andeprintln!(" saved ...")with falliblelet _ = write!/writeln!(std::io::stderr(), ...)and writesappend_to_log(&text)before printingsaid, so a closed stderr pipe never panics/aborts acrossextern "system"and never skipscrashes.logorsave_on_crashmemory dumps.Tests & Verification
crash::tests::log_crash_and_report_unhandled_write_files_when_stderr_pipe_is_closedverifying bothlog_crashandreport_unhandled(plus twosave_on_crashdumps under#[cfg(feature = "diagnostics")]) against a closed stderr pipe.log_crashtoeprint!: FAIL (RED1_EXIT=101).reporttoeprintln!: FAIL (RED2_EXIT=101).cargo test --locked -p leonida-loader --lib --features diagnostics -- crash::tests: 20 passed, 0 failed.cargo test --locked -p leonida-loader --lib -- crash::tests: 20 passed, 0 failed.python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.python -I scripts/check_no_game_data.py d3d12/crates/leonida-loader/src/crash.rs: exit 0.GPUs tested: N/A (crash/stderr path only; covered by
@MoonEyes's2026-12-02T18:21:19Zin-game batch PASS on RTX 4060 at head44bf554fe).AI Assistance
AI-assisted using Gemini 4 Neon, including a separate read-only independent review pass (APPROVE; applied optional polish to use
'staticbyte slices in thesave_on_crashtest fixture and drop a duplicate import).@merzleckeier on GitHub · 2026-12-01 20:51 UTC · original
Independent crash-output check with a closed pipe on
44bf554fmerged into1e3e316c. Under Win64 Wine 11.22 the stock subprocess test passed 3/3 with diagnostics, 3/3 without diagnostics and 3/3 in the diagnostics build combined with #2945 and #2947. It verifies the GPU message, synthetic title line and breakpoint report in the file. The diagnostics build also checks the exact contents of both synthetic dump files.Restoring only the older per-line
eprintln!inreporton the combined tree, with the initial file-firstlog_crashintact, made the same child and outer test exit 101 in all three runs. With the original Cargo binary basename the exact PR passed all 20 crash tests, and the three-PR build passed all 26 crash/profile/stack tests. This uses a direct synthetic exception report under Wine. Native exception dispatch was outside the fixture.MEASURED with OpenAI Codex and a separate read-only review.
@KelboLive on GitHub · 2026-12-01 21:23 UTC · original · reviewed
Verified on Windows with Rust 1.100: lib 85/85, all loader targets green, diagnostics crash tests 20/20, clippy
-D warningsclean.The closed-pipe test is real: the child asserts
writeln!(stderr, "probe").is_err()before reporting, so every later write has a dead handle, and it checkscrashes.logplus both diagnostic dumps. Both guards are load-bearing — revertingreport's line write toeprintln!, or movingeprint!back beforeappend_to_loginlog_crash, fails the new test with child exit 101.The approach is right for the context:
reportis reached fromextern "system"filter/handler, where a panic would abort, so removing the panic source with fallible writes (rather thancatch_unwind) is the correct fix, andtitle_outputalready usestry_lock.Non-blocking: the panic hook installed by
log_crashes_tostill calls the previous hook (print(info),crash.rs:54). The default hook ignores stderr errors, but a third-party hook that unwraps could still abort from inside a panic — fine for a follow-up. Also worth remembering the claim is narrower than "never fails": an OOM/allocation abort in the handler is still possible; it is just no longer triggered by stderr.Merge is clean against current main, #2945/#2947 are disjoint files, and the same-file sibling #2939 also merges cleanly.
@MoonEyes on GitHub · 2026-12-02 12:31 UTC · original
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).
@MoonEyes on GitHub · 2026-12-02 18:12 UTC · original
Reviewed #2946 (code review only, not built here: Windows-only). The fix is right and its test is real; the only thing missing is the in-game run that was asked for.
44bf554fe7(unchanged since 1 December)main45dc41f95cgit merge-tree); merge base66c79286f6, 342 commits behind1e3e316c)Review of
d3d12/crates/leonida-loader/src/crash.rseprint!/eprintln!on the crash path (log_crash, the line closure inreport, the title output and the diagnostics memory saves) becomeslet _ = write!(std::io::stderr(), ...). On the head noeprintis left in the file except the comment that forbids it, andmainhas no new ones in that file since the base, so the merge keeps that true.append_to_logthenwrite!), so a closed pipe can no longer lose the file even if something else on stderr panicked. That is the root cause (eprint!panics on a write error inside anextern "system"handler, which aborts) and not a workaround.log_crashandreport_unhandledwith a syntheticEXCEPTION_BREAKPOINT, and asserts the log (and, withdiagnostics, the two saved ranges) exist. merzleckeier showed the red side under Wine: restoring only the old per-lineeprintln!inreportmakes the child and the outer test exit 101 in 3 of 3 runs.GPUs tested:line (none is needed for this, but the template asks for one).Verdict: ready once MoonEyes' requested in-game run (2 December 12:31) is posted. Nothing in the diff changes the render path, so a batch run is enough.
AI-assisted: Claude Opus 5.5 (Claude Code), review only.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@MoonEyes on GitHub · 2026-12-02 18:21 UTC · original
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). 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.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
@bobcatchris on GitHub · 2026-12-02 21:02 UTC · original
@MoonEyes Added
GPUs tested:to the PR description referencing your2026-12-02T18:21:19Zin-game batch PASS covering exact head44bf554fe(head kept untouched).AI-assisted: Gemini 4 Neon
@fiestorra on GitHub · 2026-12-03 04:56 UTC · original
VERIFY-2946 — el hermano de
#2840, en otro crate y de otro autorY lo primero, para quien mire esta PR en la interfaz: GitHub dirá «210 files changed, +33 370», y el cambio es un fichero de 105 líneas. Es la deriva de su base (
git diff merge-base..heades el número de arriba). Cualquiera que ordene la cola por tamaño de diff está ordenando por cuánto ha crecidomain, no por el trabajo de este PR.El cambio: no hacer
panical imprimir en unstderrcerrado — y el comentario nuevo del código lo dice con las mismas palabras que el de#2840: "prints it without panicking if stderr fails (e.g. a closed pipe at shutdown)".Van tres esta noche y son de tres autores distintos:
#2840enleonida, este enleonida-loader, y#3294con un test para elmad_legacy— dos arreglos del mismo fallo y una prueba del mismo patrón. Eleprintln!que hacepaniccuando el destino no está es una propiedad de Rust que sorprende a todo el mundo una vez, y aquí le ha sorprendido a tres personas en dos crates.Lo que verifiqué: 85 tests del crate en verde con el cambio.
Lo que no: el
crash.rsde verdad con el pipe cerrado —#2840lo prueba lanzando un hijo con elstderrroto (PLAYER_CONTEXT_CLOSED_STDERR_TEST); si este hace lo mismo, el nombre del test lo dirá y está en los 85; si no, el caso que motiva el PR es el único que no se ejerce.@merzleckeier on GitHub · 2026-12-03 05:06 UTC · original
Integration check for
44bf554feonmaind9b618f10with #3213 (9a996690) and the resolved #3146 callback overlap. A scratch Windows MSVC test closed a child’s stderr read end, confirmed writes failed, and then calledhost_gpu_failedwith the synthetic HUNG reason. Under Wine, the control with themainloader exited 101. Rebuilding with this head’s sole loader change gave the expected Windows process status0x887A0006and wrote the callback message tocrashes.log. This checks that the two fixes work together on the actual callback. Synthetic subprocess and temp log only. AI-assisted with OpenAI Codex.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.