Skip to content

Commit

Permalink
[NFC][sanitizer] Check suspended threads outside `ThreadSuspender::Su…
Browse files Browse the repository at this point in the history
…spendThread` (#111943)

Allows to distinguish failure from stopped threads.
  • Loading branch information
vitalybuka authored Oct 11, 2024
1 parent 36b0707 commit 374886a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 374886a

Please sign in to comment.