summaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2023-05-12 10:05:46 -0700
committerVitaly Buka <vitalybuka@google.com>2023-05-12 10:15:11 -0700
commitd1aee9c0cbd8f9efc1938348a5bab8fa947c90d2 (patch)
treef7399cf5072487bf9df1329a1793f259d56c5b36 /compiler-rt
parent25159ee3af5cd1c05c010ea195b4b359df3fe820 (diff)
downloadllvm-d1aee9c0cbd8f9efc1938348a5bab8fa947c90d2.tar.gz
[sanitizers] Remove assert from ThreadArgRetval::Finish
Bionic uses pthread_exit to set retval, when GLIBC does not. This cause double call to Finish. Rather then tracking this difference on interceptor size, we can just relax precondition. It does not make a difference.
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/asan/asan_interceptors.cpp4
-rw-r--r--compiler-rt/lib/hwasan/hwasan_interceptors.cpp4
-rw-r--r--compiler-rt/lib/lsan/lsan_interceptors.cpp4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp3
4 files changed, 5 insertions, 10 deletions
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index b5767ead4a0f..2595a6adda06 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -264,9 +264,7 @@ INTERCEPTOR(int, pthread_detach, void *thread) {
}
INTERCEPTOR(int, pthread_exit, void *retval) {
- AsanThread *t = GetCurrentThread();
- if (t && t->tid() != kMainTid)
- asanThreadArgRetval().Finish(GetThreadSelf(), retval);
+ asanThreadArgRetval().Finish(GetThreadSelf(), retval);
return REAL(pthread_exit)(retval);
}
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index 75711de5a691..f87e6a2ba44c 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -107,9 +107,7 @@ INTERCEPTOR(int, pthread_detach, void *thread) {
}
INTERCEPTOR(int, pthread_exit, void *retval) {
- auto *t = GetCurrentThread();
- if (t && !t->IsMainThread())
- hwasanThreadArgRetval().Finish(GetThreadSelf(), retval);
+ hwasanThreadArgRetval().Finish(GetThreadSelf(), retval);
return REAL(pthread_exit)(retval);
}
diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index b7268163bb23..2a35572edfec 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -489,9 +489,7 @@ INTERCEPTOR(int, pthread_detach, void *thread) {
}
INTERCEPTOR(int, pthread_exit, void *retval) {
- ThreadContextLsanBase *t = GetCurrentThread();
- if (t && t->tid != kMainTid)
- GetThreadArgRetval().Finish(GetThreadSelf(), retval);
+ GetThreadArgRetval().Finish(GetThreadSelf(), retval);
return REAL(pthread_exit)(retval);
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp
index 85362e8a9721..bddb28521408 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp
@@ -39,7 +39,8 @@ ThreadArgRetval::Args ThreadArgRetval::GetArgs(uptr thread) const {
void ThreadArgRetval::Finish(uptr thread, void* retval) {
__sanitizer::Lock lock(&mtx_);
auto t = data_.find(thread);
- CHECK(t);
+ if (!t)
+ return;
if (t->second.detached) {
// Retval of detached thread connot be retrieved.
data_.erase(t);