[compiler-rt] 374886a - [NFC][sanitizer] Check suspended threads outside `ThreadSuspender::SuspendThread` (#111943)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 20:59:51 PDT 2024
Author: Vitaly Buka
Date: 2024-10-10T20:59:48-07:00
New Revision: 374886a360424d5f1c38359378a504408a9f64ed
URL: https://github.com/llvm/llvm-project/commit/374886a360424d5f1c38359378a504408a9f64ed
DIFF: https://github.com/llvm/llvm-project/commit/374886a360424d5f1c38359378a504408a9f64ed.diff
LOG: [NFC][sanitizer] Check suspended threads outside `ThreadSuspender::SuspendThread` (#111943)
Allows to distinguish failure from stopped threads.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 6ebca965f6a334..ebe7b6f2ee8cc2 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -137,10 +137,6 @@ class ThreadSuspender {
};
bool ThreadSuspender::SuspendThread(tid_t tid) {
- // Are we already attached to this thread?
- // Currently this check takes linear time, however the number of threads is
- // usually small.
- if (suspended_threads_list_.ContainsTid(tid)) return false;
int pterrno;
if (internal_iserror(internal_ptrace(PTRACE_ATTACH, tid, nullptr, nullptr),
&pterrno)) {
@@ -226,6 +222,11 @@ bool ThreadSuspender::SuspendAllThreads() {
break;
}
for (tid_t tid : threads) {
+ // Are we already attached to this thread?
+ // Currently this check takes linear time, however the number of threads
+ // is usually small.
+ if (suspended_threads_list_.ContainsTid(tid))
+ continue;
if (SuspendThread(tid))
retry = true;
else
More information about the llvm-commits
mailing list