[compiler-rt] d1aee9c - [sanitizers] Remove assert from ThreadArgRetval::Finish
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 10:15:23 PDT 2023
Author: Vitaly Buka
Date: 2023-05-12T10:15:11-07:00
New Revision: d1aee9c0cbd8f9efc1938348a5bab8fa947c90d2
URL: https://github.com/llvm/llvm-project/commit/d1aee9c0cbd8f9efc1938348a5bab8fa947c90d2
DIFF: https://github.com/llvm/llvm-project/commit/d1aee9c0cbd8f9efc1938348a5bab8fa947c90d2.diff
LOG: [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.
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index b5767ead4a0f2..2595a6adda061 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 75711de5a691f..f87e6a2ba44cb 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 b7268163bb23a..2a35572edfec0 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 85362e8a97218..bddb285214085 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);
More information about the llvm-commits
mailing list