hot-fix: Enforce minimum stack size of 64KB

Fixes some crashes in BB from unity pt 1
This commit is contained in:
TheTurtle 2024-12-11 21:17:55 +02:00 committed by GitHub
parent b82993c568
commit 0a9c437ec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -243,6 +243,13 @@ int PS4_SYSV_ABI posix_pthread_create_name_np(PthreadT* thread, const PthreadAtt
static int TidCounter = 1; static int TidCounter = 1;
new_thread->tid = ++TidCounter; new_thread->tid = ++TidCounter;
if (new_thread->attr.stackaddr_attr == 0) {
/* Enforce minimum stack size of 64 KB */
static constexpr size_t MinimumStack = 64_KB;
auto& stacksize = new_thread->attr.stacksize_attr;
stacksize = std::max(stacksize, MinimumStack);
}
if (thread_state->CreateStack(&new_thread->attr) != 0) { if (thread_state->CreateStack(&new_thread->attr) != 0) {
/* Insufficient memory to create a stack: */ /* Insufficient memory to create a stack: */
thread_state->Free(curthread, new_thread); thread_state->Free(curthread, new_thread);