aom: Ensure thread stack size is at least 256 KB (525f3)

From 525f35443198f0ffde71ad6e1a447e33e52c7772 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Mon, 29 Apr 2024 13:29:14 -0700
Subject: [PATCH] Ensure thread stack size is at least 256 KB

Fixes cases like musl where the default is lower:
https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread-stack-size

Bug: aomedia:2754, aomedia:3567
Change-Id: Ia6e211f9b87bc2efe376e7b9f4adb11741850b18
(cherry picked from commit ad5fd34ad9058384a55196f66e2001cc8c2c523f)
---
 aom_util/aom_thread.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/aom_util/aom_thread.c b/aom_util/aom_thread.c
index fa3b0a25e4..14f19e59cd 100644
--- a/aom_util/aom_thread.c
+++ b/aom_util/aom_thread.c
@@ -152,16 +152,18 @@ static int reset(AVxWorker *const worker) {
       // See: https://crbug.com/aomedia/3379
 #if defined(AOM_ADDRESS_SANITIZER) && defined(__APPLE__) && AOM_ARCH_ARM && \
     !defined(NDEBUG)
+    const size_t kMinStackSize = 1024 * 1024;
+#else
+    const size_t kMinStackSize = 256 * 1024;
+#endif
     size_t stacksize;
     if (!pthread_attr_getstacksize(&attr, &stacksize)) {
-      const size_t kMinStackSize = 1 << 20;  // 1 MiB
       if (stacksize < kMinStackSize &&
           pthread_attr_setstacksize(&attr, kMinStackSize)) {
         pthread_attr_destroy(&attr);
         goto Error2;
       }
     }
-#endif
     pthread_mutex_lock(&worker->impl_->mutex_);
     ok = !pthread_create(&worker->impl_->thread_, &attr, thread_loop, worker);
     if (ok) worker->status_ = OK;