[TSan] Make test fail more predictably

This test would hang when the system ran out of resources and we fail to
create all 300 threads.

Differential Revision: https://reviews.llvm.org/D115845
This commit is contained in:
Julian Lettner 2021-12-15 20:34:39 -08:00
parent 2d0bf14397
commit 3a1eb1cf2a
1 changed files with 7 additions and 2 deletions

View File

@ -18,8 +18,13 @@ int main() {
pthread_attr_setstacksize(&attr, 16 << 20);
for (int iter = 0; iter < kIters; iter++) {
pthread_t threads[kThreads];
for (int t = 0; t < kThreads; t++)
pthread_create(&threads[t], &attr, thr, 0);
for (int t = 0; t < kThreads; t++) {
int err = pthread_create(&threads[t], &attr, thr, 0);
if (err) {
fprintf(stderr, "Failed to create thread #%d\n", t);
return 1;
}
}
barrier_wait(&barrier);
for (int t = 0; t < kThreads; t++)
pthread_join(threads[t], 0);