fix: release discarded Vulkan resources and thread wake events #2358
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2358
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/resource-cleanup-leaks"
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?
Failed shader preparation, overlapping pipeline precompilation, and repeated thread creation can leave Vulkan objects or wake events allocated until the process exits. This releases those resources when their temporary owners are discarded.
Changes:
Validation:
49f75dc8reproduced the remaining local blockers: missing .NET SDK (updater_asset_digest, builder_details_hitbox, builder_dlss_update), missing zstandard (nup_read_name, bake_portability), Windows symlink privileges (nup_paths), missing MSVC-target windows.h (precompile_compute_guard), and the recorder_sync negative control accepting the old destructor. Its archive-only byte-compilation failure is due to lacking .git; that check passes in the actual checkout. The export also encountered a temporary executable deletion error in draw_stream_visibility.Kept as a draft while CI and gameplay validation are pending. No game run, GPU/driver memory measurement, Linux runtime test, frame-rate improvement, or device-loss fix is claimed. No renderer API or generated shader changes, and no game files are included. There is no visible UI change.
Follow-up local validation:
Latest complete local validation:
Ready for review. This PR fixes three resource leaks: shader modules left behind after failed seed translation, unpublished pipelines discarded after cache collisions, and thread wake events left open during destruction.
Local validation: 348 passed, 0 failed, 29 skipped. Windows CI passed. Linux CI needs a rerun after dependency downloads failed due to DNS resolution errors. Gameplay and GPU memory measurements are still pending.
Thanks, this is a clean, well-scoped fix. I went through all three changes:
vk_shader.cpp): on failuretranslate_into/translate_mesh_intoleave the modules they made inp->stages(the catch only setsfailed), and theProgramdies here without having been published or used by a pipeline. So destroying them is correct, nothing else holds them, and there's no double destroy. It matches the duplicate-variant branch below and thedroplambda in the compute seeding.vk_draw.cpp): withpart = -1,build_graphicsreturns a fresh pipeline that nothing else references, and it's destroyed undernote_mubefore any command buffer could see it, so there's no GPU-lifetime concern. Same pattern as the abandoned compute branch just above.hos_thread.c): the only caller isDestroyThread, which joins first, and the onlySetEventcallers (hos_svc.c) wake threads taken from the waiter table underklock, which an exited thread can't be in. So once the join returns, nothing can wait on or signalt->wake. The posix shim'sCloseHandlefreesH_EVENTobjects properly, so Linux behaves the same as Windows.The touched code is unchanged on current main (the branch is 33 behind but has no conflicts).
Nits only, none blocking:
test_thread_wake_cleanup.pyrequires the wake event to be closed after the thread handle ("wake closed before thread handle"). That order doesn't matter for correctness, so the check would fail a harmless reorder. I'd drop that assert.RUN_ALL_ARGS = ["--cc", "{cxx}"]builds C with the C++ driver through-x c. That works with clang++ and g++, but the name is a bit misleading.CI is re-running now (the earlier Linux jobs failed on apt DNS, and Windows passed). It should be green before merge.
github-sync referenced this pull request2026-11-12 06:22:54 +00:00