Skip to content

Commit 374886a

Browse files
authored
[NFC][sanitizer] Check suspended threads outside ThreadSuspender::SuspendThread (#111943)
Allows to distinguish failure from stopped threads.
1 parent 36b0707 commit 374886a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ class ThreadSuspender {
137137
};
138138

139139
bool ThreadSuspender::SuspendThread(tid_t tid) {
140-
// Are we already attached to this thread?
141-
// Currently this check takes linear time, however the number of threads is
142-
// usually small.
143-
if (suspended_threads_list_.ContainsTid(tid)) return false;
144140
int pterrno;
145141
if (internal_iserror(internal_ptrace(PTRACE_ATTACH, tid, nullptr, nullptr),
146142
&pterrno)) {
@@ -226,6 +222,11 @@ bool ThreadSuspender::SuspendAllThreads() {
226222
break;
227223
}
228224
for (tid_t tid : threads) {
225+
// Are we already attached to this thread?
226+
// Currently this check takes linear time, however the number of threads
227+
// is usually small.
228+
if (suspended_threads_list_.ContainsTid(tid))
229+
continue;
229230
if (SuspendThread(tid))
230231
retry = true;
231232
else

0 commit comments

Comments
 (0)