|
| 1 | +From 2a8989439cf4e0fa51e03ec217236f6845b54a93 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | +Date: Thu, 2 Sep 2021 14:58:18 +0200 |
| 4 | +Subject: [PATCH] Bug-1721326: Fix build with glibc-2.34 |
| 5 | + |
| 6 | +Upstream-Status: Backport [https://hg.mozilla.org/mozilla-central/rev/2ec5d7b0bc885bc0c686f7a7a5bd9d1c4bc4df9b] |
| 7 | +Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 8 | +--- |
| 9 | + js/xpconnect/src/XPCJSContext.cpp | 14 +++++++++----- |
| 10 | + 1 file changed, 9 insertions(+), 5 deletions(-) |
| 11 | + |
| 12 | +diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp |
| 13 | +index b84ed7001e..783b891457 100644 |
| 14 | +--- a/js/xpconnect/src/XPCJSContext.cpp |
| 15 | ++++ b/js/xpconnect/src/XPCJSContext.cpp |
| 16 | +@@ -84,13 +84,10 @@ using namespace xpc; |
| 17 | + using namespace JS; |
| 18 | + using mozilla::dom::AutoEntryScript; |
| 19 | + |
| 20 | +-// The watchdog thread loop is pretty trivial, and should not require much stack |
| 21 | +-// space to do its job. So only give it 32KiB or the platform minimum. |
| 22 | ++// We will clamp to reasonable values if this isn't set. |
| 23 | + #if !defined(PTHREAD_STACK_MIN) |
| 24 | + # define PTHREAD_STACK_MIN 0 |
| 25 | + #endif |
| 26 | +-static constexpr size_t kWatchdogStackSize = |
| 27 | +- PTHREAD_STACK_MIN < 32 * 1024 ? 32 * 1024 : PTHREAD_STACK_MIN; |
| 28 | + |
| 29 | + static void WatchdogMain(void* arg); |
| 30 | + class Watchdog; |
| 31 | +@@ -159,12 +156,19 @@ class Watchdog { |
| 32 | + { |
| 33 | + AutoLockWatchdog lock(this); |
| 34 | + |
| 35 | ++ // The watchdog thread loop is pretty trivial, and should not |
| 36 | ++ // require much stack space to do its job. So only give it 32KiB |
| 37 | ++ // or the platform minimum. On modern Linux libc this might resolve to |
| 38 | ++ // a runtime call. |
| 39 | ++ size_t watchdogStackSize = PTHREAD_STACK_MIN; |
| 40 | ++ watchdogStackSize = std::max<size_t>(32 * 1024, watchdogStackSize); |
| 41 | ++ |
| 42 | + // Gecko uses thread private for accounting and has to clean up at thread |
| 43 | + // exit. Therefore, even though we don't have a return value from the |
| 44 | + // watchdog, we need to join it on shutdown. |
| 45 | + mThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this, |
| 46 | + PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, |
| 47 | +- PR_JOINABLE_THREAD, kWatchdogStackSize); |
| 48 | ++ PR_JOINABLE_THREAD, watchdogStackSize); |
| 49 | + if (!mThread) { |
| 50 | + MOZ_CRASH("PR_CreateThread failed!"); |
| 51 | + } |
0 commit comments