Skip to content

Commit

Permalink
Merge pull request #64083 from knz/backport21.1-64081
Browse files Browse the repository at this point in the history
release-21.1: libroach: make DumpThreadStacks thread-safe
  • Loading branch information
knz authored May 12, 2021
2 parents 27c8482 + f51e13f commit 17de9a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions c-deps/libroach/stack_trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <memory>
#include <string>
#include <vector>
#include <mutex>

namespace {

Expand Down Expand Up @@ -306,6 +307,11 @@ std::string DumpThreadStacksHelper() {
} // namespace

std::string DumpThreadStacks() {
// This code is not thread-safe: ensure we have only one concurrent call to
// DumpThreadStacks ongoing at a time.
static std::mutex s_mutex;
std::lock_guard<std::mutex> lock(s_mutex);

struct sigaction action;
struct sigaction oldaction;
memset(&action, 0, sizeof(action));
Expand Down

0 comments on commit 17de9a2

Please sign in to comment.