Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion compiler-rt/lib/asan/tests/asan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,15 +1115,28 @@ TEST(AddressSanitizer, StressStackReuseTest) {
LotsOfStackReuse();
}

// On some platform (ex: AIX), the default thread stack size (~96 KB) is
// insufficient for this test and can lead to stack overflows.
#define MIN_STACK_SIZE (128 * 1024) // 128 KB
TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
const int kNumThreads = 20;
pthread_t t[kNumThreads];
size_t curStackSize = 0;
pthread_attr_t attr;
pthread_attr_init(&attr);
// Get the current (default) thread stack size
pthread_attr_getstacksize(&attr, &curStackSize);
if (curStackSize < MIN_STACK_SIZE) {
int rc = pthread_attr_setstacksize(&attr, MIN_STACK_SIZE);
ASSERT_EQ(0, rc);
}
for (int i = 0; i < kNumThreads; i++) {
PTHREAD_CREATE(&t[i], 0, (void* (*)(void *x))LotsOfStackReuse, 0);
PTHREAD_CREATE(&t[i], &attr, (void* (*)(void* x))LotsOfStackReuse, 0);
}
for (int i = 0; i < kNumThreads; i++) {
PTHREAD_JOIN(t[i], 0);
}
pthread_attr_destroy(&attr);
}

// pthread_exit tries to perform unwinding stuff that leads to dlopen'ing
Expand Down