Handle SIGABRT and SIGSEGV on Windows (#3511)
* Handle SIGABRT and SIGSEGV on Windows * Address code review
This commit is contained in:
parent
7bdc79c3d9
commit
f1f67265f4
1 changed files with 9 additions and 1 deletions
|
|
@ -19,6 +19,11 @@ namespace
|
||||||
{
|
{
|
||||||
void nano_abort_signal_handler (int signum)
|
void nano_abort_signal_handler (int signum)
|
||||||
{
|
{
|
||||||
|
// remove `signum` from signal handling when under Windows
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::signal (signum, SIG_DFL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// create some debugging log files
|
// create some debugging log files
|
||||||
nano::dump_crash_stacktrace ();
|
nano::dump_crash_stacktrace ();
|
||||||
nano::create_load_memory_address_files ();
|
nano::create_load_memory_address_files ();
|
||||||
|
|
@ -29,9 +34,12 @@ void nano_abort_signal_handler (int signum)
|
||||||
|
|
||||||
void install_abort_signal_handler ()
|
void install_abort_signal_handler ()
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
|
||||||
// We catch signal SIGSEGV and SIGABRT not via the signal manager because we want these signal handlers
|
// We catch signal SIGSEGV and SIGABRT not via the signal manager because we want these signal handlers
|
||||||
// to be executed in the stack of the code that caused the signal, so we can dump the stacktrace.
|
// to be executed in the stack of the code that caused the signal, so we can dump the stacktrace.
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::signal (SIGSEGV, nano_abort_signal_handler);
|
||||||
|
std::signal (SIGABRT, nano_abort_signal_handler);
|
||||||
|
#else
|
||||||
struct sigaction sa = {};
|
struct sigaction sa = {};
|
||||||
sa.sa_handler = nano_abort_signal_handler;
|
sa.sa_handler = nano_abort_signal_handler;
|
||||||
sigemptyset (&sa.sa_mask);
|
sigemptyset (&sa.sa_mask);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue