[compiler-rt] c057779 - [NFC][LSAN] Fix flaky multithreaded test
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon May 10 17:34:02 PDT 2021
Author: Vitaly Buka
Date: 2021-05-10T17:33:46-07:00
New Revision: c057779d389c5c1740a8051aa2929f7bc0f8ee00
URL: https://github.com/llvm/llvm-project/commit/c057779d389c5c1740a8051aa2929f7bc0f8ee00
DIFF: https://github.com/llvm/llvm-project/commit/c057779d389c5c1740a8051aa2929f7bc0f8ee00.diff
LOG: [NFC][LSAN] Fix flaky multithreaded test
Added:
Modified:
compiler-rt/test/lsan/TestCases/many_threads_detach.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/lsan/TestCases/many_threads_detach.cpp b/compiler-rt/test/lsan/TestCases/many_threads_detach.cpp
index 857766ddee24e..6909a483aa4ce 100644
--- a/compiler-rt/test/lsan/TestCases/many_threads_detach.cpp
+++ b/compiler-rt/test/lsan/TestCases/many_threads_detach.cpp
@@ -5,6 +5,7 @@
#include <pthread.h>
#include <stdlib.h>
+#include <unistd.h>
// Number of threads to create. This value is greater than kMaxThreads in
// lsan_thread.cpp so that we can test that thread contexts are not being
@@ -18,8 +19,8 @@ void *null_func(void *args) {
int main(void) {
for (size_t i = 0; i < kTestThreads; i++) {
pthread_t thread;
- pthread_create(&thread, NULL, null_func, NULL);
- pthread_detach(thread);
+ if (pthread_create(&thread, NULL, null_func, NULL) == 0)
+ pthread_detach(thread);
}
return 0;
}
More information about the llvm-commits
mailing list