runtime: print the call chain of a fatal fault #2276
Closed
leonida/mandy
OldSalty wants to merge 0 commits from
fault-stacks into main
pull from: fault-stacks
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/2840
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
1 participant
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!2276
Loading…
Reference in a new issue
No description provided.
Delete branch "fault-stacks"
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
This pull request cannot be reopened because the branch was deleted.
A run that ends in an exception nothing handles saves the session pipeline cache but says nothing about where the fault was: the log has
unhandled exception 0xc0000005and no call chain, so a fault in the title or one of its DLLs stays a guess. This prints the fault, what the faulting context's registers held, and the faulting thread's call chain before the caches are written.Item: none listed yet -- claimed in #1608 (see the comment linked below).
Three commits; the third answers the review's MAJOR (reconciliation in the comment below).
[rt] fault fatal: read of 0xf at <module>+0x...), or the exception code otherwise.[rt] fault fatal regs: rip ... rsp ... rbp ... rax ..., plus for each register pointing at committed readable memory a 48-byte hexdump of what it points at ([rt] fault fatal mem rax 0x...:...). A faulting read followed a pointer; the pointers still in the registers say which one, and the bytes say what the title was reading there.ranges_mutex_norg_lookup_mutex, allocates nothing, and writes through_write(_fileno(stderr))instead of stdio. A thread that faults in the DLL load path, where it already holds the loader's lock exclusively, therefore still reports instead of waiting on itself. Addresses in no published range print as bare hex.call_oncealready serialises the writers), no other-thread snapshot -- that allocates and suspends every thread; the report prints[rt] stacks fatal: other threads not sampledinstead -- and the whole report runs under__try, so a fault of the report's own printsthe report itself faultedrather than re-enteringcall_once.LEONIDA_STACKSsnapshot (snapshot_threads) still runs on the non-fatal paths (assert, device loss), where the registry and the filter's own mutex are safe to take and the title's worker pool is worth having in the same log.thread_stacks_testgains a guarded null read with stderr redirected to a temp file: the fault line names the access and the instruction, frame #0 is that same instruction, the chain unwinds out of the function the fault happened in to the function that called it, a published range names the fault's place and becomes a bare number once its owner revokes it, the other-thread line carries a synchronised helper's tid and a known frame, and the non-fatal path still names through the registry and snapshots the other threads. 39 checks, no game data.thread_stacks_teston Windows (MSVC,/W4, 0 warnings), retail run to follow.Reviewed by Claude Code (AI-assisted) on my behalf. Approving: this is the report I was missing when the title
faults.
out even if the cache write hangs.
allocated before sampling.
__tryofunwind_frame. That is fine from the filter.Non-blocking ideas, which I'm happy to do as a follow-up on top of this:
module+RVAalone it is hard to tell whichpointer was bad.
type's info.
with the CPU brand and the Windows build. Intel vs AMD decides which emulated Zen 2 instructions run.
std::string,std::vector, module lookup) where before it only printed. If the faultcame from inside the heap or while the loader's lookup mutex was held, that can hang instead of exiting. A nested
fault inside
call_oncewould block too, though that risk was already there. Not a reason to hold the PR, maybeone comment saying so.
Not built or run here: Windows-only, so this review is from reading the code.
Generated by Claude Code
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmaind48a957bb+4469914649(claim#2570#issuecomment-7239117859):runtime/src/main.cpp,runtime/src/thread_stacks.cpp,runtime/src/thread_stacks.h,runtime/test/thread_stacks_test.cpp); addsnoexceptrt::print_fault_stacksto log access-violation / exception details, unwind the live faultingCONTEXTdirectly on the crashing thread beforesave_caches_on_fatal_exceptionwaits on pipeline compiles, and snapshot remaining threads.check_no_game_data.pyclean.d48a957bb+ PR test):thread_stacks_test.cppfails to build (rc=2,error C2039: 'print_fault_stacks': is not a member of 'rt').d48a957bb+4469914649merge): Auto-merges cleanly (rc=0), compilesthread_stacks_test.exewith0warnings under/W4 /permissive-and passes (19 checks, 0 failures,rc=0), and compilesruntime/src/main.cppcleanly (0new warnings).AI-assisted.
Duplicate check (diff reading only, no build): not a duplicate. #2306 is stacked on this PR (
Depends on: #2276, and its head contains this commit), so #2276 lands first and #2306 after its rebase (it is labeledneeds rebase).Heads-up: #2276 and #2306 both conflict in
runtime/src/main.cppwith #2555 (git merge-tree). #2555 also reports a fatal exception's place, stack and registers. Worth deciding which fatal report wins before merging either side.AI-assisted (Claude Code).
RUN of #2276 (runtime: print the call chain of a fatal fault), local validation, nothing pushed.
Heads: PR head 4469914649a0c6c1f4ba0924eb6befade61fff22, main c22a0a73228cde800aff15964334e4fe9b13c889.
Merged: yes,
git merge --no-ffof the PR head into main, no conflict (merge commit 73225cbad).Commands (RelWithDebInfo, Ninja, LEONIDA_REQUIRE_VULKAN=ON, static SDL3):
cmake --build build --target thread_stacks_test gta6rt
ctest -R "^thread_stacks$" --output-on-failure -j1
Green (merged): thread_stacks passes, 22 checks, 0 failures (0.25 s). gta6rt builds. The test is a CPU test (it faults on purpose and reads its own stderr capture), not a GPU one. Other tests whose source the PR touches: none (thread_stacks_test is the only target that compiles thread_stacks.cpp besides gta6rt).
Red:
Link: no new imports vs main (gta6rt.exe, 703 DLL!symbol entries from dumpbin /imports, identical lists).
Note for the maintainer: #2276 (and #2306, which contains it) conflicts with #2555 in runtime/src/main.cpp (checked with git merge-tree of the two heads: CONFLICT in runtime/src/main.cpp). Both add a crash report with registers and stack to the fatal-exception filter, so only one of the two can go in as is, and the maintainer must pick one.
The review of timbot103 on this head (the filter calls module_offset, which takes the loader's shared lock, on the faulting thread) was not tested here: this run only shows the new test and the build pass.
Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
Verified with a negative control, and the result is worth knowing: the tests pass with the header reverted, so they do not observe the change.
1. It applies and builds. merge-tree clean onto main
d367675c7.2. With the branch:
3. The control - revert only the source change, keep the test, rebuild:
What that says: the per-thread stack capture is not observed by $(System.Collections.Hashtable.test). The test keeps passing when both the header and its wiring in main.cpp are put back to main's versions.
What I am not saying: that the change is wrong. Two readings are possible and I did not choose between them - the test may be a unit test of a header whose behaviour is unchanged in the cases it covers (in which case green either way is correct and the change is elsewhere), or it may be a test that was written beside the change rather than against it.
What would settle it in one case: a test that drives the path through the new code - e.g. for this one, the per-thread stack capture with an input that only the new code handles - and asserts on the result. If no such input exists, the change is additive and the control is expected to be green, which is also a useful thing to write in the pull request.
Why I am commenting: I verify open pull requests that replay onto current main, build the binaries their tests name, run them, then revert only the source change. A green control is a real result, and it is the one a reviewer cannot get from the diff.
Written with an AI assistant.
Independent check on Windows (not the author), at
e480a5e7b.thread_stacks_testand ran it: 39 checks, 0 failures — including the capture's file opens, a published range naming the fault's place, and the same address becoming a bare number once the owner revokes it.Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.
AI-assisted: yes (opencode).