Skip to content

Commit dc0ccbd

Browse files
authored
[compiler-rt][asan] Fix a test on Windows (#167591)
Windows doesn't support `pthread_attr`, which was introduced to asan_test.cpp in #165198, so this change `#ifdef`s out the changes made in that PR. Originally reported by Chrome as https://crbug.com/459880605.
1 parent abb8c4b commit dc0ccbd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ TEST(AddressSanitizer, StressStackReuseTest) {
11211121
TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
11221122
const int kNumThreads = 20;
11231123
pthread_t t[kNumThreads];
1124+
// pthread_attr isn't supported on Windows.
1125+
#ifndef _WIN32
11241126
size_t curStackSize = 0;
11251127
pthread_attr_t attr;
11261128
pthread_attr_init(&attr);
@@ -1130,13 +1132,20 @@ TEST(AddressSanitizer, ThreadedStressStackReuseTest) {
11301132
int rc = pthread_attr_setstacksize(&attr, MIN_STACK_SIZE);
11311133
ASSERT_EQ(0, rc);
11321134
}
1135+
#endif
11331136
for (int i = 0; i < kNumThreads; i++) {
1137+
#ifdef _WIN32
1138+
PTHREAD_CREATE(&t[i], 0, (void* (*)(void* x))LotsOfStackReuse, 0);
1139+
#else
11341140
PTHREAD_CREATE(&t[i], &attr, (void* (*)(void* x))LotsOfStackReuse, 0);
1141+
#endif
11351142
}
11361143
for (int i = 0; i < kNumThreads; i++) {
11371144
PTHREAD_JOIN(t[i], 0);
11381145
}
1146+
#ifndef _WIN32
11391147
pthread_attr_destroy(&attr);
1148+
#endif
11401149
}
11411150

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

0 commit comments

Comments
 (0)