fix(agc): keep the shader preparation lifecycle mutex alive through exit #9738
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9738"
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 mugurc on 2026-10-22T11:07:06Z.
What
agc_driver_registration_prepare_stackpasses its checks on macOS and then ends interminatewith "mutex lock failed: Invalid argument" as the process exits. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).The driver singleton's destructor runs at exit, and
Driver::stopcloses the shader preparation pools throughCloseRegistrationPreparation, which locks the pools' lifecycle mutex. That mutex is a function-local static, constructed on its first use, after the driver, so it is destroyed before the driver's destructor runs. glibc locks a destroyed mutex without complaint; macOS fails the lock withEINVAL, andstd::mutex::lockthrows.The mutex is now allocated once and never destroyed, as the pools it guards already are.
Tested
macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2, no Vulkan loader. The libraries do not link on macOS without the rest of the macOS series, so the run is on
main7e2ba73e4with the series (ci/macos-series-2on my fork) and the libSceSsl change of #7332.__cxa_throw, shows the throw at exit:exit→__cxa_finalize_ranges→Driver::~Driver→Driver::stop→CloseRegistrationPreparation→std::mutex::lock.agc_driver_registration_prepare_stackfails without this PR and passes with it, 3 runs of 3.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:54:07Z.
I compared this exact change with open #8658. Its current head already changes
RegistrationPreparePool::Lifecycle()to the same never-destroyednew std::mutexon Apple (static auto* lifecycle = new std::mutex). The pairwise merge also conflicts inShaderRegistry.cpp, and #8658 includes substantially broader macOS support.Please clarify the intended merge order for this duplicate hunk. If this standalone fix should land first, record the relationship/order and make sure #8658 removes or rebases over the duplicate; if #8658 is intended to supply it, this PR should not land the same change independently. The current
Depends on: noneleaves the overlap unresolved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:59:38Z.
Review: CHANGES_REQUESTED
There are two merge blockers: 1. Open #8658 already contains the identical
RegistrationPreparePool::Lifecycle()change on Apple (static auto* lifecycle = new std::mutex), and the current pairwise merge conflicts inShaderRegistry.cpp. Please agree with #8658’s author which change lands first and record the ordering/dependency; make sure the final branch contains the fix once. 2. This is a new generic PR withUnblocks: none. The focused macOS reproduction is useful evidence. This branch is also 4 commits behind currentmain; if it proceeds later, refresh and rerun the focused exit test and overlap check. Current product CI jobs are skipped.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.