Skip to content

Conversation

@alanzhao1
Copy link
Contributor

Windows doesn't support pthread_attr, which was introduced to asan_test.cpp in #165198, so this change #ifdefs out the changes made in that PR.

Originally reported by Chrome as https://crbug.com/459880605.

Windows doesn't support `pthread_attr`, which was introduced to
asan_test.cpp in llvm#165198, so this change `#ifdef`s out the changes made
in that PR.

Originally reported by Chrome as https://crbug.com/459880605.
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2025

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

Author: Alan Zhao (alanzhao1)

Changes

Windows doesn't support pthread_attr, which was introduced to asan_test.cpp in #165198, so this change #ifdefs out the changes made in that PR.

Originally reported by Chrome as https://crbug.com/459880605.


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

1 Files Affected:

  • (modified) compiler-rt/lib/asan/tests/asan_test.cpp (+9)
diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp
index 59d64ac4753ca..0f2535f816083 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cpp
+++ b/compiler-rt/lib/asan/tests/asan_test.cpp
@@ -1121,6 +1121,8 @@ TEST(AddressSanitizer, StressStackReuseTest) {
 TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
   const int kNumThreads = 20;
   pthread_t t[kNumThreads];
+// pthread_attr isn't supported on Windows.
+#ifndef _WIN32
   size_t curStackSize = 0;
   pthread_attr_t attr;
   pthread_attr_init(&attr);
@@ -1130,13 +1132,20 @@ TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
     int rc = pthread_attr_setstacksize(&attr, MIN_STACK_SIZE);
     ASSERT_EQ(0, rc);
   }
+#endif
   for (int i = 0; i < kNumThreads; i++) {
+#ifdef _WIN32
+    PTHREAD_CREATE(&t[i], 0, (void* (*)(void *x))LotsOfStackReuse, 0);
+#else
     PTHREAD_CREATE(&t[i], &attr, (void* (*)(void* x))LotsOfStackReuse, 0);
+#endif
   }
   for (int i = 0; i < kNumThreads; i++) {
     PTHREAD_JOIN(t[i], 0);
   }
+#ifndef _WIN32
   pthread_attr_destroy(&attr);
+#endif
 }
 
 // pthread_exit tries to perform unwinding stuff that leads to dlopen'ing

@github-actions
Copy link

github-actions bot commented Nov 11, 2025

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

@alanzhao1 alanzhao1 merged commit dc0ccbd into llvm:main Nov 11, 2025
7 of 9 checks passed
@alanzhao1 alanzhao1 deleted the bugfix/asan-test-windows branch November 11, 2025 23:02
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.

2 participants