Skip to content

Commit

Permalink
community/aom: use patch to fix stack size
Browse files Browse the repository at this point in the history
  • Loading branch information
andypost authored and maxice8 committed Mar 8, 2021
1 parent 699d16b commit 45f670a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 3 deletions.
8 changes: 5 additions & 3 deletions community/aom/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
# Maintainer: Oleg Titov <[email protected]>
pkgname=aom
pkgver=1.0.0
pkgrel=1
pkgrel=2
pkgdesc="Alliance for Open Media (AOM) AV1 codec SDK"
url="https://aomedia.org/"
arch="all"
license="custom"
options="!check" # No test suite from upstream
makedepends="cmake perl python3 yasm"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://aomedia.googlesource.com/aom/+archive/v$pkgver-errata1-avif.tar.gz"
source="$pkgname-$pkgver.tar.gz::https://aomedia.googlesource.com/aom/+archive/v$pkgver-errata1-avif.tar.gz
fix-stack-size-e53da0b.patch"

case "$CARCH" in
ppc64le) makedepends="$makedepends linux-headers" ;;
Expand Down Expand Up @@ -55,4 +56,5 @@ unpack() {
-C "$builddir" > /dev/null
}

sha512sums="ea5226a72c048ee460ee798083990cbed91341875bb2998263d67078c3317efbe523f71d6b8dae420cf6691216befa9117f73a90132b4f5b09ed0f470f658e06 aom-1.0.0.tar.gz"
sha512sums="accf23a65f896ed111c2c781eae155838719e904d4ba59059c9151b446a3fa9ce6d2a40fb5df8e5096fd5346aa71a82241f451aa241a07decb5fa5be41393c96 aom-1.0.0.tar.gz
573a6c9cd1e9c71a0612f750fb1b69ee65ab86364d3aa78ef51b8fb20633c69b97026d0685dedeabb51f31d0dab7c651d1fe5c72e0dc9f14b8ed2704584934a9 fix-stack-size-e53da0b.patch"
78 changes: 78 additions & 0 deletions community/aom/fix-stack-size-e53da0b.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
From e53da0b1bf2652896bed7b65929a1d8d0729d922 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[email protected]>
Date: Thu, 27 Aug 2020 20:49:03 -0700
Subject: [PATCH] Ensure thread stack size is at least 256 KB

BUG=aomedia:2754

Change-Id: Ia6e211f9b87bc2efe376e7b9f4adb11741850b18
---

diff --git a/aom_util/aom_thread.c b/aom_util/aom_thread.c
index a749a22..8411569 100644
--- a/aom_util/aom_thread.c
+++ b/aom_util/aom_thread.c
@@ -133,16 +133,39 @@
goto Error;
}
if (pthread_cond_init(&worker->impl_->condition_, NULL)) {
- pthread_mutex_destroy(&worker->impl_->mutex_);
- goto Error;
+ goto Error1;
}
+ pthread_attr_t *attr = NULL;
+#if HAVE_PTHREAD_H
+ pthread_attr_t thread_attributes;
+ attr = &thread_attributes;
+ if (pthread_attr_init(attr)) {
+ goto Error2;
+ }
+ size_t stack_size;
+ if (pthread_attr_getstacksize(attr, &stack_size)) {
+ pthread_attr_destroy(attr);
+ goto Error2;
+ }
+ const size_t kMinStackSize = 256 * 1024;
+ if (stack_size < kMinStackSize &&
+ pthread_attr_setstacksize(attr, kMinStackSize)) {
+ pthread_attr_destroy(attr);
+ goto Error2;
+ }
+#endif // HAVE_PTHREAD_H
pthread_mutex_lock(&worker->impl_->mutex_);
- ok = !pthread_create(&worker->impl_->thread_, NULL, thread_loop, worker);
+ ok = !pthread_create(&worker->impl_->thread_, attr, thread_loop, worker);
if (ok) worker->status_ = OK;
pthread_mutex_unlock(&worker->impl_->mutex_);
+#if HAVE_PTHREAD_H
+ pthread_attr_destroy(attr);
+#endif
if (!ok) {
- pthread_mutex_destroy(&worker->impl_->mutex_);
+ Error2:
pthread_cond_destroy(&worker->impl_->condition_);
+ Error1:
+ pthread_mutex_destroy(&worker->impl_->mutex_);
Error:
aom_free(worker->impl_);
worker->impl_ = NULL;
diff --git a/aom_util/aom_thread.h b/aom_util/aom_thread.h
index 8d04312..efbed78 100644
--- a/aom_util/aom_thread.h
+++ b/aom_util/aom_thread.h
@@ -32,6 +32,7 @@
#include <process.h> // NOLINT
#include <windows.h> // NOLINT
typedef HANDLE pthread_t;
+typedef int pthread_attr_t;
typedef CRITICAL_SECTION pthread_mutex_t;

#if _WIN32_WINNT < 0x0600
@@ -147,6 +148,7 @@
#include <sys/builtin.h> // NOLINT

#define pthread_t TID
+#define pthread_attr_t int
#define pthread_mutex_t HMTX

typedef struct {

0 comments on commit 45f670a

Please sign in to comment.