Skip to content

Commit f906dfd

Browse files
committed
Linux: implement throwing exception from signal handlers
1 parent 6fd2c18 commit f906dfd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
6565
endif()
6666
endif()
6767

68-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17 -Wno-attributes -pipe -fvisibility=hidden -Wl,--no-undefined")
68+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17 -Wno-attributes -pipe -fvisibility=hidden -Wl,--no-undefined -fnon-call-exceptions")
6969
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") This is for the future versions
7070
#set(CMAKE_CXX_STANDARD 14) #Otherwise adds -std=gnu++11 and breaks successful building
7171
#set(CMAKE_CXX_STANDARD_REQUIRED ON)

src/xrCore/xrDebug.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ void xrDebug::SetupExceptionHandler()
670670
#else
671671
const auto minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
672672
#endif
673-
673+
674674
BT_SetDumpType(minidumpFlags);
675675
//BT_SetSupportEMail("[email protected]");
676676
BT_SetSupportEMail("[email protected]");
@@ -817,7 +817,7 @@ static void unexpected_handler() { handler_base("unexpected program termination"
817817
static void abort_handler(int signal) { handler_base("application is aborting"); }
818818
static void floating_point_handler(int signal) { handler_base("floating point error"); }
819819
static void illegal_instruction_handler(int signal) { handler_base("illegal instruction"); }
820-
static void segmentation_fault_handler(int signal) { handler_base("segmentation fault"); }
820+
void segmentation_fault_handler(int signal) { throw std::runtime_error("segfault"); }
821821
static void termination_handler(int signal) { handler_base("termination with exit code 3"); }
822822

823823
void xrDebug::OnThreadSpawn()
@@ -843,12 +843,12 @@ void xrDebug::OnThreadSpawn()
843843
std::set_unexpected(_terminate);
844844
#endif
845845
#else //WINDOWS
846+
signal(SIGSEGV, sigsegv_handler);
847+
std::set_terminate(_terminate);
846848
signal(SIGABRT, abort_handler);
847849
signal(SIGFPE, floating_point_handler);
848850
signal(SIGILL, illegal_instruction_handler);
849851
signal(SIGINT, 0);
850-
signal(SIGTERM, termination_handler);
851-
signal(SIGSEGV, segmentation_fault_handler);
852852
#endif
853853
}
854854

0 commit comments

Comments
 (0)