[compiler-rt] b088833 - tsan: deflake dlopen_static_tls.cpp

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 03:01:44 PST 2021


Author: Dmitry Vyukov
Date: 2021-12-13T12:01:40+01:00
New Revision: b08883337531feb2b72aee89164c80480aa9d7dc

URL: https://github.com/llvm/llvm-project/commit/b08883337531feb2b72aee89164c80480aa9d7dc
DIFF: https://github.com/llvm/llvm-project/commit/b08883337531feb2b72aee89164c80480aa9d7dc.diff

LOG: tsan: deflake dlopen_static_tls.cpp

Currently the test calls dlclose in the thread
concurrently with the main thread calling a function
from the dynamic library. This is not good.
Wait for the main thread to call the function
before calling dlclose.

Depends on D115612.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D115613

Added: 
    

Modified: 
    compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp b/compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp
index a53fc70346ad3..f97348d54f772 100644
--- a/compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp
+++ b/compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp
@@ -49,6 +49,7 @@ void *thread(void *arg) {
   barrier_wait(&barrier);
   if (__atomic_load_n(&ready, __ATOMIC_ACQUIRE))
     func();
+  barrier_wait(&barrier);
   if (dlclose(lib)) {
     printf("error in dlclose: %s\n", dlerror());
     exit(1);
@@ -73,6 +74,7 @@ int main(int argc, char *argv[]) {
   __atomic_store_n(&ready, 1, __ATOMIC_RELEASE);
   barrier_wait(&barrier);
   func();
+  barrier_wait(&barrier);
   pthread_join(th, 0);
   fprintf(stderr, "DONE\n");
   return 0;


        


More information about the llvm-commits mailing list