Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lovell/3e70b51079af2c9b78e5a0e6f6ad0e59 to your computer and use it in GitHub Desktop.
Save lovell/3e70b51079af2c9b78e5a0e6f6ad0e59 to your computer and use it in GitHub Desktop.
From 6a795a5aa5bea94d544d3668caaf1c64881aaa1a Mon Sep 17 00:00:00 2001
From: Lovell Fuller <github@lovell.info>
Date: Thu, 11 Jan 2024 13:20:15 +0000
Subject: [PATCH] Ensure thread stack size is at least 256 KB
This matches the behaviour of the Alpine Linux patch
https://git.alpinelinux.org/aports/tree/main/aom/fix-stack-size-e53da0b.patch
---
aom_util/aom_thread.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/aom_util/aom_thread.c b/aom_util/aom_thread.c
index fa3b0a25e4..62a68c25fc 100644
--- a/aom_util/aom_thread.c
+++ b/aom_util/aom_thread.c
@@ -147,21 +147,15 @@ static int reset(AVxWorker *const worker) {
}
pthread_attr_t attr;
if (pthread_attr_init(&attr)) goto Error2;
- // Debug ASan builds require at least ~1MiB of stack; prevents
- // failures on macOS arm64 where the default is 512KiB.
- // See: https://crbug.com/aomedia/3379
-#if defined(AOM_ADDRESS_SANITIZER) && defined(__APPLE__) && AOM_ARCH_ARM && \
- !defined(NDEBUG)
size_t stacksize;
if (!pthread_attr_getstacksize(&attr, &stacksize)) {
- const size_t kMinStackSize = 1 << 20; // 1 MiB
+ const size_t kMinStackSize = 256 * 1024;
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment