Skip to content

Commit 1409e63

Browse files
committed
[Asan] Ensure minimum stack size 128KB in ThreadedStressStackReuseTest
This test fails on AIX due to smaller default thread stack size. Set thread stack size to a minimum of 128KB to ensure reliable test behavior across platforms.
1 parent 3dce567 commit 1409e63

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler-rt/lib/asan/tests/asan_test.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,15 +1115,30 @@ TEST(AddressSanitizer, StressStackReuseTest) {
11151115
LotsOfStackReuse();
11161116
}
11171117

1118+
// On some platform (ex: AIX), the default thread stack size (~96 KB) is
1119+
// insufficient for this test and can lead to stack overflows. The test
1120+
// has been updated to accomodate platforms with smaller default thread
1121+
// stack sizes.
1122+
#define MIN_STACK_SIZE (128 * 1024) // Minimum stack size to use: 128 KB
11181123
TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
11191124
const int kNumThreads = 20;
11201125
pthread_t t[kNumThreads];
1126+
size_t curStackSize = 0;
1127+
pthread_attr_t attr;
1128+
pthread_attr_init(&attr);
1129+
// Get the current (default) thread stack size
1130+
pthread_attr_getstacksize(&attr, &curStackSize);
1131+
if (curStackSize < MIN_STACK_SIZE) {
1132+
int rc = pthread_attr_setstacksize(&attr, MIN_STACK_SIZE);
1133+
ASSERT_EQ(0, rc);
1134+
}
11211135
for (int i = 0; i < kNumThreads; i++) {
1122-
PTHREAD_CREATE(&t[i], 0, (void* (*)(void *x))LotsOfStackReuse, 0);
1136+
PTHREAD_CREATE(&t[i], &attr, (void* (*)(void *x))LotsOfStackReuse, 0);
11231137
}
11241138
for (int i = 0; i < kNumThreads; i++) {
11251139
PTHREAD_JOIN(t[i], 0);
11261140
}
1141+
pthread_attr_destroy(&attr);
11271142
}
11281143

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

0 commit comments

Comments
 (0)