[compiler-rt] c16fa77 - [NFC][HWASAN] Fix pthread_attr_getdetachstate use
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 01:07:41 PDT 2023
Author: Vitaly Buka
Date: 2023-05-18T01:07:20-07:00
New Revision: c16fa77c35fb2eac82feaf6320e869f1a82cc184
URL: https://github.com/llvm/llvm-project/commit/c16fa77c35fb2eac82feaf6320e869f1a82cc184
DIFF: https://github.com/llvm/llvm-project/commit/c16fa77c35fb2eac82feaf6320e869f1a82cc184.diff
LOG: [NFC][HWASAN] Fix pthread_attr_getdetachstate use
Luckely of Linux PTHREAD_CREATE_DETACHED is 1.
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index f87e6a2ba44c..443bfe8108dc 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -68,9 +68,10 @@ INTERCEPTOR(int, pthread_create, void *thread, void *attr,
void *(*callback)(void *), void *param) {
EnsureMainThreadIDIsCorrect();
ScopedTaggingDisabler tagging_disabler;
- int detached = 0;
- if (attr)
- pthread_attr_getdetachstate(attr, &detached);
+ bool detached = [attr]() {
+ int d = 0;
+ return attr && !pthread_attr_getdetachstate(attr, &d) && IsStateDetached(d);
+ }();
ThreadStartArg *A = (ThreadStartArg *)InternalAlloc(sizeof(ThreadStartArg));
ScopedBlockSignals block(&A->starting_sigset_);
// ASAN uses the same approach to disable leaks from pthread_create.
More information about the llvm-commits
mailing list