diff --git a/c-deps/libroach/stack_trace.cc b/c-deps/libroach/stack_trace.cc index 7434481b6600..1005682fcf83 100644 --- a/c-deps/libroach/stack_trace.cc +++ b/c-deps/libroach/stack_trace.cc @@ -30,6 +30,7 @@ #include #include #include +#include namespace { @@ -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 lock(s_mutex); + struct sigaction action; struct sigaction oldaction; memset(&action, 0, sizeof(action));