Skip to content

Commit

Permalink
tsan: deflake dlopen_static_tls.cpp
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dvyukov committed Dec 13, 2021
1 parent 7de546e commit b088833
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler-rt/test/tsan/Linux/dlopen_static_tls.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit b088833

Please sign in to comment.