Commit 745d6044 authored by robliao's avatar robliao Committed by Commit bot

Scale Stack Limits in ThreadTest.StartWithOptions_StackSize with Bitness

12 kb may be too small for a 64-bit machine. This allows enough
breathing space for the thread local storage teardown later on.

BUG=590907

Review-Url: https://codereview.chromium.org/2395303002
Cr-Commit-Position: refs/heads/master@{#423710}
parent 3988c1fd
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <vector> #include <vector>
...@@ -136,14 +137,16 @@ void ReturnThreadId(base::Thread* thread, ...@@ -136,14 +137,16 @@ void ReturnThreadId(base::Thread* thread,
TEST_F(ThreadTest, StartWithOptions_StackSize) { TEST_F(ThreadTest, StartWithOptions_StackSize) {
Thread a("StartWithStackSize"); Thread a("StartWithStackSize");
// Ensure that the thread can work with only 12 kb and still process a // Ensure that the thread can work with only 12 kb and still process a
// message. // message. At the same time, we should scale with the bitness of the system
// where 12 kb is definitely not enough.
// 12 kb = 3072 Slots on a 32-bit system, so we'll scale based off of that.
Thread::Options options; Thread::Options options;
#if defined(ADDRESS_SANITIZER) || !defined(NDEBUG) #if defined(ADDRESS_SANITIZER) || !defined(NDEBUG)
// ASan bloats the stack variables and overflows the 12 kb stack. Some debug // ASan bloats the stack variables and overflows the 3072 slot stack. Some
// builds also grow the stack too much. // debug builds also grow the stack too much.
options.stack_size = 24*1024; options.stack_size = 2 * 3072 * sizeof(uintptr_t);
#else #else
options.stack_size = 12*1024; options.stack_size = 3072 * sizeof(uintptr_t);
#endif #endif
EXPECT_TRUE(a.StartWithOptions(options)); EXPECT_TRUE(a.StartWithOptions(options));
EXPECT_TRUE(a.message_loop()); EXPECT_TRUE(a.message_loop());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment