From 7db1c3333302d4d5ac97a5cfb28e88e5c2cde968 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:52:34 -0800 Subject: [PATCH] Fix multiple dumps from being generated (#80708) Issue: https://github.com/dotnet/runtime/issues/78956 After a core dump is generated because of a unhandled managed exception abort() is called but a SIGSEGV is generated in libpthread.so which is caught by the runtime and a second core dump is generated. The fix is to uninstall/uninitialize all the signal handlers, not just SIGABORT. Co-authored-by: Mike McLaughlin --- src/coreclr/pal/src/exception/signal.cpp | 16 ---------------- src/coreclr/pal/src/include/pal/signal.hpp | 10 ---------- src/coreclr/pal/src/thread/process.cpp | 5 +++-- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/coreclr/pal/src/exception/signal.cpp b/src/coreclr/pal/src/exception/signal.cpp index 108b64ae9954d1..7d299212db6411 100644 --- a/src/coreclr/pal/src/exception/signal.cpp +++ b/src/coreclr/pal/src/exception/signal.cpp @@ -294,22 +294,6 @@ void SEHCleanupSignals() } } -/*++ -Function : - SEHCleanupAbort() - - Restore default SIGABORT signal handlers - - (no parameters, no return value) ---*/ -void SEHCleanupAbort() -{ - if (g_registered_signal_handlers) - { - restore_signal(SIGABRT, &g_previous_sigabrt); - } -} - /* internal function definitions **********************************************/ /*++ diff --git a/src/coreclr/pal/src/include/pal/signal.hpp b/src/coreclr/pal/src/include/pal/signal.hpp index 9dca625635df3c..6a3e41b4de473f 100644 --- a/src/coreclr/pal/src/include/pal/signal.hpp +++ b/src/coreclr/pal/src/include/pal/signal.hpp @@ -117,14 +117,4 @@ Function : --*/ void SEHCleanupSignals(); -/*++ -Function : - SEHCleanupAbort() - - Restore default SIGABORT signal handlers - - (no parameters, no return value) ---*/ -void SEHCleanupAbort(); - #endif /* _PAL_SIGNAL_HPP_ */ diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 69c7fe04326a4e..81fab952f2f265 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2677,8 +2677,9 @@ PROCAbort(int signal) PROCCreateCrashDumpIfEnabled(signal); - // Restore the SIGABORT handler to prevent recursion - SEHCleanupAbort(); + // Restore all signals; the SIGABORT handler to prevent recursion and + // the others to prevent multiple core dumps from being generated. + SEHCleanupSignals(); // Abort the process after waiting for the core dump to complete abort();