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 | 9a370ccca241a93f3cfe8a8bd46dbab25a8d6cb8 (patch) | |
| tree | 2b86a917761a4041dcfab7c5138181970229abbb /compiler-rt/lib | |
| parent | c18e9ecd4fc1f8bce7cf1ad0a63cb64a3fc40040 (diff) | |
| download | bcm5719-llvm-9a370ccca241a93f3cfe8a8bd46dbab25a8d6cb8.tar.gz bcm5719-llvm-9a370ccca241a93f3cfe8a8bd46dbab25a8d6cb8.zip | |
[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
llvm-svn: 354005
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index ba0599e333b..58b9c39e35c 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -1118,8 +1118,12 @@ void MSanAtExitWrapper() { void MSanCxaAtExitWrapper(void *arg) { UnpoisonParam(1); MSanAtExitRecord *r = (MSanAtExitRecord *)arg; + // libc before 2.27 had race which caused occasional double handler execution + // https://sourceware.org/ml/libc-alpha/2017-08/msg01204.html + if (!r->func) + return; r->func(r->arg); - InternalFree(r); + r->func = nullptr; } static int setup_at_exit_wrapper(void(*f)(), void *arg, void *dso); |

