diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-02-14 02:51:55 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-02-14 02:51:55 +0000 |
commit | a776aa8033ee64c54e1bc3712cb7772fd823dd57 (patch) | |
tree | 81ae9de6cefb03ae7d4e04234e36d7fb27872bf8 /test/msan | |
parent | 27bd2841c5e1ba16250087271776b213f8abe409 (diff) | |
download | compiler-rt-a776aa8033ee64c54e1bc3712cb7772fd823dd57.tar.gz |
[msan] Don't delete MSanAtExitRecord
Summary:
Pre 2.27 libc can run same atexit handler twice
We will keep MSanAtExitRecord and reset fun to mark it as executed.
Fix PR40162
Reviewers: eugenis
Subscribers: jfb, jdoerfert, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D58221
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/msan')
-rw-r--r-- | test/msan/cxa_atexit_race.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/msan/cxa_atexit_race.cc b/test/msan/cxa_atexit_race.cc new file mode 100644 index 000000000..f6e7a225b --- /dev/null +++ b/test/msan/cxa_atexit_race.cc @@ -0,0 +1,35 @@ +// RUN: %clangxx_msan %s -o %t && %run %t 2>&1 | FileCheck %s + +#include <atomic> +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +extern "C" int +__cxa_atexit(void (*func)(void *), void *arg, void *d); + +void handler(void *) { +} + +std::atomic_int counter; + +void *thread(void *) { + for (int i = 0; i < 10000; ++i) { + __cxa_atexit(&handler, 0, (void *)&handler); + ++counter; + } + return 0; +} + +int main(void) { + printf("TEST_MAIN\n"); + pthread_t pt; + for (int i = 0; i < 2; ++i) + pthread_create(&pt, 0, &thread, 0); + while (counter < 1000) { + }; + return 0; +} +// CHECK: TEST_MAIN +// CHECK-NOT: MemorySanitizer |