Skip to content

Commit

Permalink
Fix multiple dumps from being generated (#80708)
Browse files Browse the repository at this point in the history
Issue: #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 <mikem@microsoft.com>
  • Loading branch information
github-actions[bot] and mikem8361 committed Jan 17, 2023
1 parent c8a73af commit 7db1c33
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 28 deletions.
16 changes: 0 additions & 16 deletions src/coreclr/pal/src/exception/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 **********************************************/

/*++
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/pal/src/include/pal/signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
5 changes: 3 additions & 2 deletions src/coreclr/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7db1c33

Please sign in to comment.