diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-27 11:32:21 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-27 11:32:21 +0000 |
commit | cfc29de659f3abbb9273fb0fb1c9a3cd5400c81b (patch) | |
tree | 01d9f6bdb649b3c9730e762343d7efab289e4d9c /lib/msan/msan_interceptors.cc | |
parent | c78773e8c3db9e191e736acdc608e7d81ac42513 (diff) | |
download | compiler-rt-cfc29de659f3abbb9273fb0fb1c9a3cd5400c81b.tar.gz compiler-rt-cfc29de659f3abbb9273fb0fb1c9a3cd5400c81b.tar.bz2 compiler-rt-cfc29de659f3abbb9273fb0fb1c9a3cd5400c81b.tar.xz |
[msan] Unpoison argument shadow for C++ module destructors.
Fixes PR17377.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191508 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan_interceptors.cc')
-rw-r--r-- | lib/msan/msan_interceptors.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc index ebff67a6..0d5c848d 100644 --- a/lib/msan/msan_interceptors.cc +++ b/lib/msan/msan_interceptors.cc @@ -19,6 +19,7 @@ #include "msan.h" #include "sanitizer_common/sanitizer_platform_limits_posix.h" #include "sanitizer_common/sanitizer_allocator.h" +#include "sanitizer_common/sanitizer_allocator_internal.h" #include "sanitizer_common/sanitizer_atomic.h" #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_stackdepot.h" @@ -1083,6 +1084,30 @@ INTERCEPTOR(void, tzset) { return; } +struct MSanAtExitRecord { + void (*func)(void *arg); + void *arg; +}; + +void MSanAtExitWrapper(void *arg) { + UnpoisonParam(1); + MSanAtExitRecord *r = (MSanAtExitRecord *)arg; + r->func(r->arg); + InternalFree(r); +} + +// Unpoison argument shadow for C++ module destructors. +INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, + void *dso_handle) { + if (msan_init_is_running) return REAL(__cxa_atexit)(func, arg, dso_handle); + ENSURE_MSAN_INITED(); + MSanAtExitRecord *r = + (MSanAtExitRecord *)InternalAlloc(sizeof(MSanAtExitRecord)); + r->func = func; + r->arg = arg; + return REAL(__cxa_atexit)(MSanAtExitWrapper, r, dso_handle); +} + struct MSanInterceptorContext { bool in_interceptor_scope; }; @@ -1340,6 +1365,7 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(pthread_key_create); INTERCEPT_FUNCTION(pthread_join); INTERCEPT_FUNCTION(tzset); + INTERCEPT_FUNCTION(__cxa_atexit); inited = 1; } } // namespace __msan |