Windows: tests whose exe imports a .prx hang under ctest when the registration lacks the unpatched-dir PATH prepend #7637
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 akkadbakkad89 on 2026-10-18T18:53:04Z.
Symptom
On Windows, a test whose executable imports
libc.prx/libSceAgcDriver.prx(i.e. links a prx target) but whoseadd_testregistration lacksnever reaches
main(). The loader resolveslib*.prximports to the patched copy inlibs/(or fails to find one at all), shows "The procedure entry point ... could not be located" (0xC0000139), and the process blocks on the modal dialog until ctest reports Timeout — a dialog, not a readable failure.Repro
Live instance in open PR #7627:
agc_driver_depth_bounds_stateis registered without the WIN32ENVIRONMENT_MODIFICATIONits sibling registrations get. Underctest -R agc_driver_depth_bounds_stateon Windows it exhausts the timeout on both NVIDIA RTX 3070 and Intel UHD 630; run by hand withlibs\unpatchedonPATHit passes in ~1 s (Depth bounds state checks passed).The same mechanism makes any direct run of these exes fail with
0xC0000139for a developer who does not know to prepend the unpatched dir first.Why it keeps happening
The prepend is manual per-test boilerplate repeated ~570 times across ~95
CMakeLists.txtfiles; every new registration must remember it, and nothing checks that it did. Linux/macOS never need it (rpath), so authors on those platforms cannot see the breakage.Proposed fix
Stage each test executable's linked
.prxruntime artifacts next to the exe (the executable's own directory outranksPATHin the Windows DLL search order) via$<TARGET_RUNTIME_DLLS:...>inadd_test_executable— no registration then needs the prepend, future omissions stop mattering, and hand-running a test exe works with no environment setup. ExistingENVIRONMENT_MODIFICATIONlines stay harmless.I intend to implement this. Filing first for visibility in case the approach is wrong.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T18:54:12Z.
I verified the reported omission in open PR #7627:
agc_driver_graphics_testslinkslibc, butagc_driver_depth_bounds_statehas no WindowsPATHprepend while sibling cases do. I also checked the proposedTARGET_RUNTIME_DLLSdirection against the rootadd_test_executablehelper: test executables share${CMAKE_BINARY_DIR}/tests, and the helper currently handles MinGW entry wrapping only. Please validate that staging runtime files there cannot collide across tests and that CMake includes the custom.prxtargets before replacing the registration-level fix; I will not duplicate the implementation while you are preparing it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T18:55:09Z.
Update: the concrete missing-PATH case is now fixed in #7627 at
33f65a7ebaf. I had overlooked the author’s follow-up when I raised the shared-directory staging concern; that concern does not apply to the focused registration fix. The broader automatic-staging proposal remains unimplemented, and I do not have evidence yet that the shared helper can safely stage every custom.prxdependency without collisions.Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-18T19:03:12Z.
Both questions checked on a working branch (
fix/test-prx-dll-staging,add_test_executablegained a POST_BUILDcmake -E copy -t $<TARGET_FILE_DIR:t> $<TARGET_RUNTIME_DLLS:t>):.prxtargets are covered:agc_driver_graphics_testslinkslibc/libkernel/libSceAgcDriverand the generated build line copies exactly those threeunpatched/*.prxfiles intotests/. Confirmed on disk:tests/libSceAgcDriver.prx,tests/libkernel.prx,tests/libc.prx. Exes with no shared-library deps (nid_buffer_validation_tests) build clean - empty$<TARGET_RUNTIME_DLLS>is a no-op.tests/dir: every prx target emits the samelibs/unpatchedoutput set, so all exes stage identical bytes;copy -toverwrite is idempotent. Single-config Ninja tree, one variant per build. Where it can still bite: a stale exe kept across a head switch loads a stale staged copy - but that hazard already exists today via the prepend (PATH points atunpatched/, which is equally stale in that scenario), so the change is risk-neutral there.End-to-end proof:
agc_driver_graphics_tests.exerun directly withPATH=C:\Windows\System32;C:\Windows(no unpatched dir anywhere) passes the whole graphics suite - the loader resolves the.prximports from the exe's own directory. And a ctest sweep (agc_write_tracking,agc_buffer_pool, recorder import/storage modes,guest_kernel_sys,guest_cpu_time_clocks,nid_buffer_validation, host-import cases): 14/14 pass, 1 skip by design. RTX 3070, driver 617.42, Windows 11, MinGW GCC 15.2.0, Release.Existing
ENVIRONMENT_MODIFICATIONprepends stay in place; this removes the trap for the next registration that forgets them.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T19:21:26Z.
I tested the proposed POST_BUILD staging command with CMake 3.25.1 and a MinGW Windows cross-target.
cmake -E copy -t "$<TARGET_FILE_DIR:t>" "$<TARGET_RUNTIME_DLLS:t>"fails for both one and three linked.prxtargets:copy -ttreats the final expanded runtime file as the target, then reports that it is not a directory. The staging direction still works when usingcmake -E copy_if_different "$<TARGET_RUNTIME_DLLS:t>" "$<TARGET_FILE_DIR:t>/"withCOMMAND_EXPAND_LISTS; I verified the generated command and copied all three artifacts beside the executable in the cross-target build. Since you have a working branch, could you update that command and submit the PR? I won’t open a competing PR while you’re actively preparing this change.Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-18T19:22:28Z.
Implementation is up: #7645 stages each test exe's linked
.prxruntime files next to the executable inadd_test_executable, so the loader resolves them from the exe directory instead of the PATH prepend.Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-18T19:25:04Z.
Good catch -
cmake -E copy -tis indeed newer-than-3.25 syntax. Updated #7645 to your verified form plus one guard:$<TARGET_FILE>is listed as a trailing source so a target with zero shared-library dependencies still gets a well-formed command (self-copy of an identical file is a no-op; an emptycopy_if_differenterrors on old cmake). Re-verified on cmake 4.4.4:agc_driver_graphics_testsstages libc/libkernel/libSceAgcDriver.prx,nid_buffer_validation_testsbuilds clean, direct run with scrubbed PATH passes the full graphics suite, ctest sweep green. New headd2fbfd925.