From 08373314fc9ecd8beddd194186938261c7e72b54 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 11 Jul 2023 14:17:54 +0800 Subject: [PATCH 1/3] fix: https://github.com/bombela/backward-cpp/issues/303 --- backward.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backward.hpp b/backward.hpp index 670aa45..f42124e 100644 --- a/backward.hpp +++ b/backward.hpp @@ -330,10 +330,10 @@ #endif #endif // defined(BACKWARD_SYSTEM_DARWIN) +#include #if defined(BACKWARD_SYSTEM_WINDOWS) #include -#include #include #include @@ -4287,12 +4287,14 @@ class SignalHandling { private: details::handle _stack_content; bool _loaded; + static std::recursive_mutex _mu; #ifdef __GNUC__ __attribute__((noreturn)) #endif static void sig_handler(int signo, siginfo_t *info, void *_ctx) { + std::lock_guard lk(_mu); handleSignal(signo, info, _ctx); // try to forward the signal. From 27d75da7c9344dd4d8fd9a4a1ec5ee39c0b9ea6a Mon Sep 17 00:00:00 2001 From: David Date: Tue, 11 Jul 2023 14:21:20 +0800 Subject: [PATCH 2/3] fix: not resethand --- backward.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backward.hpp b/backward.hpp index f42124e..778f037 100644 --- a/backward.hpp +++ b/backward.hpp @@ -4209,7 +4209,7 @@ class SignalHandling { struct sigaction action; memset(&action, 0, sizeof action); action.sa_flags = - static_cast(SA_SIGINFO | SA_ONSTACK | SA_NODEFER | SA_RESETHAND); + static_cast(SA_SIGINFO | SA_ONSTACK | SA_NODEFER); sigfillset(&action.sa_mask); sigdelset(&action.sa_mask, posix_signals[i]); #if defined(__clang__) From 24065883fcafe5070162af4413eeb25f3b89b8cc Mon Sep 17 00:00:00 2001 From: David Date: Tue, 11 Jul 2023 17:39:18 +0800 Subject: [PATCH 3/3] fix: remove the raise signal in signal handler --- backward.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backward.hpp b/backward.hpp index 778f037..b6dce44 100644 --- a/backward.hpp +++ b/backward.hpp @@ -4287,7 +4287,7 @@ class SignalHandling { private: details::handle _stack_content; bool _loaded; - static std::recursive_mutex _mu; + static std::mutex _mu; #ifdef __GNUC__ __attribute__((noreturn)) @@ -4297,8 +4297,6 @@ class SignalHandling { std::lock_guard lk(_mu); handleSignal(signo, info, _ctx); - // try to forward the signal. - raise(info->si_signo); // terminate the process immediately. puts("watf? exit");