[compiler-rt][asan] Fix a test on Windows#167591
Merged
Conversation
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.
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Alan Zhao (alanzhao1) ChangesWindows doesn't support Originally reported by Chrome as https://crbug.com/459880605. Full diff: https://github.com/llvm/llvm-project/pull/167591.diff 1 Files Affected:
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
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.