fix(agc): check the deferred destruction resolver only against live devices #11705
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11705"
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?
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T04:16:15Z.
What
Deferred destruction (#10062, MoltenVK only) keeps the
vkGetDeviceProcAddrof the first device in a process-wide registry and throwsdeferred destruction found two different device resolverswhen a later device brings a different pointer. The registry never forgets it: it is still there after its device is gone.VulkanDeviceunloads the Vulkan loader withSDL_UnloadObjectwhen the device goes, and on macOS the nextSDL_LoadObjectcan maplibvulkan.1.dylibat another address. In an x86_64 probe, threedlopen/dlsym("vkGetDeviceProcAddr")/dlcloserounds returned0x10937b240,0x1094ea240and0x10937b240. So every test that opens a secondVulkanDevicein the same process fails at device setup. imellag saw the same message on 9 tests in #11551, changing from run to run.The registry now keeps the resolver of every device it set up and passes each device's calls through its own one, so a wrapper returned for an earlier device keeps reaching that device's loader after a later device is set up. The most recent resolver is used only for devices the registry never set up. A device set up after the last deferred device went may bring a different resolver; two live devices with different resolvers still throw.
agc_deferred_destructiongets a case that sets up a device, destroys its deferred objects, and sets up the next one with a different resolver, as after a loader reload. It checks that the next device is accepted and passes through to its own resolver, that the earlier device's wrapper still passes through to the earlier resolver (MarcZX10's review), and that a second live device with the first resolver is still refused.Tested
macOS 27.2, Apple M2 Max, x86_64 Release under Rosetta 2.
mainalone doesn't build on macOS yet, so the GPU runs usemain27ad7244d2plus the open macOS build PRs (#10366, #7631, #10659, #10660, #11249, #11358, #10669, #10552, #7804, #10540, #10676, #11447, #11437) and #11554, which loadslibvulkan.1.dyliband makes this reachable.ANYPS5_NO_SHADER_CACHE=1,ctest -R '^agc' -j1 --timeout 30, without the flip, display andlds_atomics64tests (1027 tests).deferred destruction found two different device resolvers(2 of those as 30 s timeouts);agc_driver_indirect_arguments_pending_producerloadslibvulkan.so.1on macOS,agc_driver_stencil_ref_export_unusedhits a MoltenVK MSL compile error,agc_driver_rect_list_indirectpasses on MoltenVK main with KhronosGroup/SPIRV-Cross#2704 (signed zero). No test fails with the change that passes without it.agc_deferred_destruction(the test andDeferredDestruction.cppbuilt alone, macOS x86_64 Apple clang and Linux Ubuntu GCC 15.2, same results): onmain'sDeferredDestruction.cppthe new case fails with "a device set up after the last one went could not use a resolver from a reloaded Vulkan loader"; on the first head of this PR (be7db251a) it fails with "an earlier device's wrapper passed through to a later device's resolver"; at the current head the whole test passes.be7db251a), not re-run at the current head. Both heads pass a live device's calls to that device's own resolver; they differ only for calls on a device after a later device was set up, whichVulkanDevicedoesn't make (it destroys the device right afterDestroyDeferredObjects).agc_driver_address_passes,clamped_global_fill,compute_table_calls,depth_copy_draw,host_import_teardown,indexed_copy) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1,ctest -V: all pass, the layer loads, noVUID-errors. Without the change they stop at device setup, so there is no run to compare against.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T04:55:21Z.
Review: CHANGES_REQUESTED
Reviewed exact head
be7db251ad005c9ead50177d190b9f04a17743f9against current mainddd72f488b6070c3864c8782cc5691ca3e30e680. Changes requested for one reproduced resolver-routing regression.[P2] Preserve the resolver for a previously returned device-proc wrapper across reload.
deferringDeviceProcroutes passthrough calls through the single process-wideregistry().resolver. This change replaces that resolver whenever the registry has no deferred devices. AfterDeferDestructionToIdle(first, mockProc)andDestroyDeferredObjects(first), setting upsecondwithreloadedProcchanges what the already-returnedfirstProcroutes to:firstProc(first, "vkQueueWaitIdle")now returnsreloadedQueueWaitIdle, notmockQueueWaitIdle. I reproduced this by compiling the exact PR implementation/test with that additional assertion; it fails.DestroyDeferredObjectsonly removes deferred tracking; productionVulkanDevicecalls it beforevkDestroyDevice, so the old device may still be live during this interval. The existing test explicitly expects a previously returned wrapper to pass through afterDestroyDeferredObjects, but does not cover a subsequent resolver replacement.Please preserve resolver routing for that old wrapper/device across the reload (or establish that this transition is unsupported and remove the stale-wrapper behavior contract), and add a regression for the sequence above. The requested loader-reload case and the two-live-device rejection should both remain covered.
Current-main conventions and
git diff --checkpass. Hosted policy checks pass; product test jobs are skipped by path policy. This review's additional focused resolver regression was compiled and executed locally; it did not run the full AGC suite.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T05:18:34Z.
Review: APPROVED
Re-reviewed exact head
846e2989232e60ebb4c1720c7bdb8d68b095b928.The updated per-device resolver map fixes the earlier-wrapper regression: a wrapper returned for the first device retains that device's resolver after a later loader reload, while the new device uses its own resolver. The live-device resolver mismatch guard remains, and the regression test now checks both routing directions plus rejection of two live devices with different resolvers.
I applied the exact PR changes since the current-main merge base in a disposable review tree, built
agc_deferred_destruction_tests, and ranctest -R '^agc_deferred_destruction$': 1/1 passed. The normal host CPU guard was bypassed only in that scratch tree for this CPU-only test, then restored; tracked source is clean. The PR correctly distinguishes GPU-suite numbers from its previous head; its current-head focused tests pass on Linux and macOS per the author. Hosted eligibility, conventions and label checks pass; product jobs are skipped by path policy.No blocking issue found in the updated diff.