Merge pull request #1375 from gjonn/fix/guest-raise-exception-host-lock-race

test(libkernel): fix host-mutex handshake race in guest_raise_exception
This commit is contained in:
Dean
2026-10-08 15:19:00 +13:00
committed by GitHub
+3
View File
@@ -73,6 +73,7 @@ static std::mutex hostLock;
static constexpr int HostRounds = 20;
static std::atomic<int> hostRound{0};
static std::atomic<int> hostAcquired{0};
static void* APS5_VABI HostBlocked(void* arg) {
auto& worker = *static_cast<Worker*>(arg);
@@ -81,6 +82,7 @@ static void* APS5_VABI HostBlocked(void* arg) {
while (hostRound.load() != round) std::this_thread::yield();
worker.started.store(true);
std::lock_guard lock(hostLock);
hostAcquired.store(round + 1);
}
return nullptr;
}
@@ -164,6 +166,7 @@ int main() {
Require(sceKernelRaiseException(blockedThread, SIGUSR1) == 0);
hostLock.unlock();
ExpectDelivery(1 + 2 * Repeats + round, blocked.id);
while (hostAcquired.load() != round + 1) std::this_thread::yield();
hostLock.lock();
blocked.started.store(false);
hostRound.store(round + 1);