runtime: keep present dump capture buffer across splash handoff #1738
Closed
leonida/mandy
quietfold wants to merge 0 commits from
fix/present-dump-splash-handoff into main
pull from: fix/present-dump-splash-handoff
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!1738
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/present-dump-splash-handoff"
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.
Item ID:
RT-PRESENT-DUMP-SPLASH-HANDOFFClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7159613942
Addresses finding: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157589788 (
LEONIDA_PRESENT_DUMPaccess violation inucrtbase.dllwhen the splash hands off to the first title frame)Root cause
VulkanPresenter::present_splash()(runtime/src/vulkan_present_splash.h:16) setssplash_capture_only_ = enable_capture()whencapture_was false. On the first non-black title frame (show_title == true),VulkanPresenter::submit_now()(runtime/src/vulkan_present.h:648-655) unconditionally calledrelease_capture()whiledump_.enabled()was still true, settingcapture_ptr_ = nullptrwhile leavingcapture_size_non-zero.On the next
dump_.due(shown - 1)frame (including the handoff frame itself if it falls on the interval, or the first post-handoff interval frame such as frame 150 at,30or 300 at,150),dump_.save(..., capture_ptr_, size_t(capture_size_))passed(nullptr, nullptr + capture_size_)tostd::vector<std::uint8_t>, crashing with an access violation reading address0insideucrtbase.dll(memcpy).In addition, when
!dump_.enabled(),release_capture()ran afterfinish_startup_frame()had waited only on the current ring slot'sframe.donefence, without waiting on the other in-flight slot inframes_.Changes
runtime/src/present_dump.h:should_release_capture_after_splash(bool splash_capture_only, bool dump_enabled)(splash_capture_only && !dump_enabled).valid_frame_buffer(extent, format, src, size, &needed).PresentDump::save()to validate viavalid_frame_buffer()before copyingsrc .. src + needed, disabling cleanly instead of dereferencing null or reading pastsize.runtime/src/vulkan_present.h:capture_buffer_/capture_ptr_alive across splash handoff whendump_.enabled()is true (still clearingsplash_capture_only_andcapture_so only due dump frames copy viafinish_image()).!dump_.enabled()), wait on allframes_fences before callingrelease_capture().capture_size_ = 0inrelease_capture()and onvkCreateBufferfailure, and guard!capture_ptr_ || !capture_size_beforedump_.save().runtime/test/present_dump_test.cpp&runtime/CMakeLists.txt:present_dump_testcoveringshould_release_capture_after_splash,valid_frame_bufferedge/overflow cases, andPresentDump::save()valid PNG + null/truncated/overflow/invalid-format guards.runtime/test/vk_present_dump_test.cpp&runtime/CMakeLists.txt:--splashmode (vk_present_dump_splash) exercisingpresent_splash()->present_blank()-> non-black title handoffpresent()on a due frame ->present_blank()->present_planes(), checkingvalidation_errors() == 0and all 3 PNG outputs.Verification
runtime/test/present_dump_test.cppwithclang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefinedagainst a temporary localVkFormat/VkExtent2Dstub (not committed): PASS.main:runtime/src/present_dump.hpassing(nullptr, 16)toPresentDump::save(): reproduced UBSan null-pointer arithmetic + ASan SEGV reading0x0(exit 134).python3 -I scripts/check_no_game_data.py runtime/src/present_dump.h runtime/src/vulkan_present.h runtime/test/present_dump_test.cpp runtime/test/vk_present_dump_test.cpp runtime/CMakeLists.txt: PASS.python3 -I tests/test_text_write_line_endings.py: 3/3 OK.runtime/src/vulkan_present.handruntime/test/vk_present_dump_test.cpp(vk_present_dump_splash) are Win32/Vulkan and were not compiled or executed on macOS; they require Windows CI / a Vulkan GPU run.### Clean-Room & Technical Verification
main(bcaa13dad) is 100% clean with zero merge conflicts.check_no_game_data.pyclean).VulkanPresenter::submit_now()previously unconditionally calledrelease_capture()upon the first non-black title frame whensplash_capture_only_was set, leavingcapture_ptr_ = nullptrwhilecapture_size_remained non-zero. Subsequent frame dumps dereferenced null intostd::vector, triggering an access violation inucrtbase.dll.should_release_capture_after_splash(splash_capture_only, dump_.enabled()), ensuringcapture_buffer_andcapture_ptr_remain valid across splash dismissal wheneverLEONIDA_PRESENT_DUMPis active.valid_frame_buffer().present_dump_testand Vulkan lifecycle testvk_present_dump_test --splash.LGTM! Approved.
Tested on Windows with a GPU, since the PR says the Vulkan parts were not compiled or run. @kevincommits found the same crash today (item 1 of https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7225370093), and this PR already fixes it. I withdrew my claim on that item in favour of this one. Thanks @IlyassRS3.
Setup: profile M, NVIDIA GeForce RTX 4070 SUPER, 12 GB, driver 621.01, Windows 11. This branch was merged locally onto current
main(43a9d562d) with no conflicts; nothing was pushed.vk_present_dump_test --splashwithLEONIDA_VK_VALIDATION=1: passes 3/3 runs. It writespresent_000001/3/5.png, with 0 validation errors.src/present_dump.handsrc/vulkan_present.hreverted tomain: SIGSEGV on all 3 runs, right after frame 1 is dumped. So the new test reproduces the crash, and the fix removes it.ctest -R "present|splash": 13/14 pass. These includevk_present_dump,_default,_invalid,_splash,present_dump,vk_presenter_sync,vk_presenter_sparse_capture,d3d12_present,xs_present_lazyandpackage_splash. The failure isxbox_present, which also fails onmainunchanged on this machine.One small gap, which kevincommits also pointed out and which could go here or in a follow-up: in
recreate(),if (capture_ && stride != 4) return false;returns afterswapchain_/extent_/format_already describe the new swapchain, but the capture buffer still has the old extent's size.release_capture()before thatreturn falsewould leave nothing stale behind. Today the presenter stops after a failed recreate, andvalid_frame_buffer()insave()refuses a too-small buffer, so I don't see a crash from it. It would only be for consistency.The branch shows as mergeable. A merge from
mainwould refresh its CI.AI-assisted (Claude Code)
Windows 11 + MSVC
19.44+ RTX 3090 Verification — PASS (336e4edec8)Verified
336e4edec8merged ontoorigin/main(e66c65b950/16f5053047,0conflicts, plus a 5-way combined merge alongside#1146,#988,#955, and#2544) on native Windows 11 (10.0.26200.9974) with MSVC19.44.35228, NVIDIA GeForce RTX 3090, andVK_LAYER_KHRONOS_validation1.4.363.1.Checks Run
vk_present_dump_test --splashagainstorigin/mainheaders on NVIDIA GeForce RTX 3090):#1738'svk_present_dump_test.cppagainst unpatchedorigin/mainruntime/src/vulkan_present.handruntime/src/present_dump.hand ran--splash: crashed with0xc0000005(STATUS_ACCESS_VIOLATION) after dumping frame 1 (present_000001.png), when frame 3's launch-splash dismissal freedcapture_buffer_(capture_ptr_ == nullptr) whileLEONIDA_PRESENT_DUMPremained active.#1738 + origin/main):present_dump_test.exe(/W4 /WX, CPU unit suite): compiled with0warnings under/W4 /WXand passed (rc=0), verifyingshould_release_capture_after_splash, overflow-safevalid_frame_buffer,needed-bounded byte slicing, and null/short/overflow disable guards.vk_present_dump_test.exeacross all 4 CTest modes on NVIDIA GeForce RTX 3090 (LEONIDA_VK_VALIDATION=1):vk_present_dump_test(interval2):rc=0,0VUID-errors.vk_present_dump_test --default(interval60):rc=0,0VUID-errors.vk_present_dump_test --invalid(interval0):rc=0,0VUID-errors.vk_present_dump_test --splash(blue splash frame 1 -> orange handoff frame 3 -> composed orange/black frame 5):rc=0, all 3 PNGs verified pixel-for-pixel,0VUID-errors.tests/test_ctest_registration.pyandtests/test_ci_registration.pypassed (rc=0).AI-assisted.
RUN #1738 | head 336e4edec844628c8cb35e1321f02e6e51911090, merged cleanly with main 54b2a81e95c470c953ddee6177fd6255cbaf041d (local merge, not pushed)
Commands (from the repository root, in a worktree):
Green (merged tree, GPU tests one at a time):
present_dump,vk_present_dump,vk_present_dump_default,vk_present_dump_invalid,vk_present_dump_splash(new),vk_presenter_sync,vk_presenter_sparse_capturepass.d3d12_boot_movieis skipped (reports skip).xbox_presentfails (present failed (VkResult -11), 4 of 4 runs), and it fails the same way on plain main 54b2a81e9 (rebuilt and run there), so it is pre-existing and not caused by this pull request.Red, three ways, each with the PR's tests kept and only the non-test source changed:
runtime/src/present_dump.handruntime/src/vulkan_present.hreverted to main:present_dump_testdoes not build (new APIshould_release_capture_after_splashmissing, build failure only), andvk_present_dump_splashbuilds and crashes (SegFault). This is the crash the pull request describes.PresentDump::save()removed (the new helpers stay):present_dumpcrashes (SegFault).vulkan_present.hreverted (PR'spresent_dump.hkept):vk_present_dump_splashfails, with the dump disabled ("buffer is missing or smaller than the frame") and the third PNG missing; the other threevk_present_dump*tests still pass.Link: no new imports vs main (gta6rt.exe, 723 DLL!symbol entries, same list as the baseline built from main).
Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1.
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.