forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-02-17 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 0b2cb722d3d256e20d265ed5421e286e0589d182 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 19 Mar 2021 20:09:10 -0700
Subject: [PATCH 2/3] adjust thread stack sizes
 
musl default stack is 128K as compared to glibc's 8M
adjust the expecations accordingly
 
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 base/threading/platform_thread_linux.cc      | 3 ++-
 chrome/app/shutdown_signal_handlers_posix.cc | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -439,7 +439,8 @@ void TerminateOnThread() {}
 
 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
 #if !defined(THREAD_SANITIZER)
-  return 0;
+  // use 8mb like glibc to avoid running out of space
+  return (1 << 23);
 #else
   // ThreadSanitizer bloats the stack heavily. Evidence has been that the
   // default stack size isn't enough for some browser tests.
--- a/base/threading/platform_thread_unittest.cc
+++ b/base/threading/platform_thread_unittest.cc
@@ -408,7 +408,7 @@ TEST(PlatformThreadTest, GetDefaultThrea
     ((defined(OS_LINUX) || defined(OS_CHROMEOS)) &&              \
      !defined(THREAD_SANITIZER)) ||                              \
     (defined(OS_ANDROID) && !defined(ADDRESS_SANITIZER))
-  EXPECT_EQ(0u, stack_size);
+  EXPECT_EQ(1u << 23, stack_size);
 #else
   EXPECT_GT(stack_size, 0u);
   EXPECT_LT(stack_size, 20u * (1 << 20));
--- a/chrome/browser/shutdown_signal_handlers_posix.cc
+++ b/chrome/browser/shutdown_signal_handlers_posix.cc
@@ -187,11 +187,19 @@ void InstallShutdownSignalHandlers(
   g_shutdown_pipe_read_fd = pipefd[0];
   g_shutdown_pipe_write_fd = pipefd[1];
 #if !defined(ADDRESS_SANITIZER)
+# if defined(__GLIBC__)
   const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2;
+# else
+  const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2 * 8; // match up musls 2k PTHREAD_STACK_MIN with glibcs 16k
+# endif
 #else
+# if defined(__GLIBC__)
   // ASan instrumentation bloats the stack frames, so we need to increase the
   // stack size to avoid hitting the guard page.
   const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4;
+# else
+  const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4 * 8; // match up musls 2k PTHREAD_STACK_MIN with glibcs 16k
+# endif
 #endif
   ShutdownDetector* detector = new ShutdownDetector(
       g_shutdown_pipe_read_fd, std::move(shutdown_callback), task_runner);