fix(libkernel): return EINVAL for unknown mutex attribute types

UFC 6 (PPSA23566) passes type 0 to pthread_mutexattr_settype during
startup. libkernel rejects it with EINVAL and leaves the attribute
unchanged, as fpPS4's decompiled body does, instead of aborting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chad
2026-10-06 16:36:52 -05:00
parent edf90b169f
commit 69973800a7
2 changed files with 4 additions and 1 deletions
@@ -1,5 +1,6 @@
#include "../include/Pthread.hpp"
#include "../include/Mutex.hpp"
#include "prx/libkernel/KernelErrors.hpp"
#include "prx/libkernel/Time/include/TimedWait.hpp"
#include <atomic>
#include <chrono>
@@ -114,7 +115,7 @@ int APS5_VABI scePthreadMutexattrSettype(PthreadMutexattr* attr, int type) {
case 2: (*attr)->type = MutexType::Recursive; break;
case 3: (*attr)->type = MutexType::Normal; break;
case 4: (*attr)->type = MutexType::Adaptive; break;
default: throw std::invalid_argument("Invalid mutex type");
default: return SCE_KERNEL_ERROR_EINVAL;
}
return 0;
}
+2
View File
@@ -83,6 +83,8 @@ int main() {
PthreadMutexattr attr = nullptr;
Require(scePthreadMutexattrInit(&attr) == SCE_OK);
Require(scePthreadMutexattrSettype(&attr, MUTEX_TYPE_ERRORCHECK) == SCE_OK);
Require(scePthreadMutexattrSettype(&attr, 0) == SCE_KERNEL_ERROR_EINVAL);
Require(scePthreadMutexattrSettype(&attr, 5) == SCE_KERNEL_ERROR_EINVAL);
Require(scePthreadMutexattrSetprotocol(&attr, PRIO_NONE) == SCE_OK);
Require(scePthreadMutexattrSetprotocol(&attr, PRIO_INHERIT) == SCE_OK);
bool protectionRejected = false;