Skip to content

Conversation

@riyaz86a
Copy link

Asan test ThreadedStressStackReuseTest 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 (platforms with smaller default thread stack size).

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Oct 27, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Riyaz Ahmad (riyaz86a)

Changes

Asan test ThreadedStressStackReuseTest 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 (platforms with smaller default thread stack size).


Full diff: https://github.com/llvm/llvm-project/pull/165198.diff

1 Files Affected:

  • (modified) compiler-rt/lib/asan/tests/asan_test.cpp (+16-1)
diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp
index 2d23a12cc6ae2..4fc5c978f82a5 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cpp
+++ b/compiler-rt/lib/asan/tests/asan_test.cpp
@@ -1115,15 +1115,30 @@ 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. The test
+// has been updated to accomodate platforms with smaller default thread
+// stack sizes.
+#define MIN_STACK_SIZE (128 * 1024)  //  Minimum stack size to use: 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

@riyaz86a
Copy link
Author

@jakeegan @tonykuttai

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.
@github-actions
Copy link

github-actions bot commented Oct 28, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@riyaz86a
Copy link
Author

Code formatter failed, updated the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants