summaryrefslogtreecommitdiff
path: root/absl/debugging/failure_signal_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/debugging/failure_signal_handler.cc')
-rw-r--r--absl/debugging/failure_signal_handler.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc
index ef8ab9e5..9f399d02 100644
--- a/absl/debugging/failure_signal_handler.cc
+++ b/absl/debugging/failure_signal_handler.cc
@@ -33,6 +33,10 @@
#include <sys/mman.h>
#endif
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
#include <algorithm>
#include <atomic>
#include <cerrno>
@@ -172,6 +176,20 @@ static bool SetupAlternateStackOnce() {
if (sigaltstack(&sigstk, nullptr) != 0) {
ABSL_RAW_LOG(FATAL, "sigaltstack() failed with errno=%d", errno);
}
+
+#ifdef __linux__
+#if defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
+ // Make a best-effort attempt to name the allocated region in
+ // /proc/$PID/smaps.
+ //
+ // The call to prctl() may fail if the kernel was not configured with the
+ // CONFIG_ANON_VMA_NAME kernel option. This is OK since the call is
+ // primarily a debugging aid.
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, sigstk.ss_sp, sigstk.ss_size,
+ "absl-signalstack");
+#endif
+#endif // __linux__
+
return true;
}