[compiler-rt] 2394f09 - [ASAN][LSAN] Ignore main or uninitialized thead in pthread_exit
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 22:58:48 PDT 2023
Author: Vitaly Buka
Date: 2023-05-11T22:58:09-07:00
New Revision: 2394f091df0bba3f8c5362df1f7b6502cc837f66
URL: https://github.com/llvm/llvm-project/commit/2394f091df0bba3f8c5362df1f7b6502cc837f66
DIFF: https://github.com/llvm/llvm-project/commit/2394f091df0bba3f8c5362df1f7b6502cc837f66.diff
LOG: [ASAN][LSAN] Ignore main or uninitialized thead in pthread_exit
Fix crash on CHECK in ThreadArgRetval::Finish().
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 7d658e527e17..b5767ead4a0f 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -23,6 +23,7 @@
#include "asan_suppressions.h"
#include "asan_thread.h"
#include "lsan/lsan_common.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_libc.h"
// There is no general interception at all on Fuchsia.
@@ -263,7 +264,9 @@ INTERCEPTOR(int, pthread_detach, void *thread) {
}
INTERCEPTOR(int, pthread_exit, void *retval) {
- asanThreadArgRetval().Finish(GetThreadSelf(), retval);
+ AsanThread *t = GetCurrentThread();
+ if (t && t->tid() != kMainTid)
+ asanThreadArgRetval().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 2a35572edfec..b7268163bb23 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -489,7 +489,9 @@ INTERCEPTOR(int, pthread_detach, void *thread) {
}
INTERCEPTOR(int, pthread_exit, void *retval) {
- GetThreadArgRetval().Finish(GetThreadSelf(), retval);
+ ThreadContextLsanBase *t = GetCurrentThread();
+ if (t && t->tid != kMainTid)
+ GetThreadArgRetval().Finish(GetThreadSelf(), retval);
return REAL(pthread_exit)(retval);
}
More information about the llvm-commits
mailing list