Skip to content

Commit

Permalink
Linux createdump: skip/ignore ptrace suspend on threads that have ter…
Browse files Browse the repository at this point in the history
…minated (dotnet#106058)

Issue: dotnet#104256
  • Loading branch information
mikem8361 committed Aug 7, 2024
1 parent 6278482 commit c26ed9f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/coreclr/debug/createdump/crashinfounix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,20 @@ CrashInfo::EnumerateAndSuspendThreads()
pid_t tid = static_cast<pid_t>(strtol(entry->d_name, nullptr, 10));
if (tid != 0)
{
// Reference: http://stackoverflow.com/questions/18577956/how-to-use-ptrace-to-get-a-consistent-view-of-multiple-threads
// Reference: http://stackoverflow.com/questions/18577956/how-to-use-ptrace-to-get-a-consistent-view-of-multiple-threads
if (ptrace(PTRACE_ATTACH, tid, nullptr, nullptr) != -1)
{
int waitStatus;
waitpid(tid, &waitStatus, __WALL);
}
else
{
printf_error("Problem suspending threads: ptrace(ATTACH, %d) FAILED %s (%d)\n", tid, strerror(errno), errno);
printf_error("Problem suspending thread: ptrace(ATTACH, %d) FAILED %s (%d)\n", tid, strerror(errno), errno);
// If the ptrace on a thread that has already terminated, skip/ignore
if (errno == ESRCH && tid != CrashThread())
{
continue;
}
closedir(taskDir);
return false;
}
Expand Down

0 comments on commit c26ed9f

Please sign in to comment.