-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Print backtraces when exceptions are thrown Currently does so by printing them in the exception constructor, as otherwise we wouldn't be able to check for expected query result messages. Also adds a std::terminate handler to handle some unexpected exits which would otherwise not print traces * Add support for SIGSEGV backtraces (and other signals) * Ignore false positive GCC warning in relwithdebinfo mode
- Loading branch information
1 parent
7251ee6
commit 4e1a9fd
Showing
11 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
add_library(kuzu_common_exception | ||
OBJECT | ||
exception.cpp | ||
message.cpp) | ||
|
||
if (ENABLE_BACKTRACES) | ||
target_link_libraries(kuzu_common_exception PRIVATE cpptrace::cpptrace) | ||
endif() | ||
|
||
set(ALL_OBJECT_FILES | ||
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common_exception> | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "common/exception/exception.h" | ||
|
||
#ifdef KUZU_BACKTRACE | ||
#include <cpptrace/cpptrace.hpp> | ||
#endif | ||
|
||
namespace kuzu { | ||
namespace common { | ||
|
||
Exception::Exception(std::string msg) : exception(), exception_message_(std::move(msg)) { | ||
#ifdef KUZU_BACKTRACE | ||
cpptrace::generate_trace(1 /*skip this function's frame*/).print(); | ||
#endif | ||
} | ||
|
||
} // namespace common | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if (ENABLE_BACKTRACES) | ||
add_library(register_backtrace_signal_handler OBJECT register.cpp) | ||
target_link_libraries(register_backtrace_signal_handler cpptrace::cpptrace) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifdef KUZU_BACKTRACE | ||
#include <csignal> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <iostream> | ||
|
||
#include <cpptrace/cpptrace.hpp> | ||
|
||
namespace { | ||
|
||
void handler(int signo) { | ||
// Not safe. Safe method would be writing directly to stderr with a pre-defined string | ||
// But since the below isn't safe either... | ||
std::cerr << "Fatal signal " << signo << std::endl; | ||
// This is not safe, however the safe version, described at the link below, | ||
// was causing hangs when the tracer program can't be found. | ||
// Since this is only used in CI, the occasional failure/hang is probably acceptable. | ||
// https://github.com/jeremy-rifkin/cpptrace/blob/main/docs/signal-safe-tracing.md | ||
cpptrace::generate_trace(1 /*skip this function's frame*/).print(); | ||
std::_Exit(1); | ||
} | ||
|
||
int register_signal_handlers() noexcept { | ||
std::signal(SIGSEGV, handler); | ||
std::signal(SIGFPE, handler); | ||
cpptrace::register_terminate_handler(); | ||
return 0; | ||
} | ||
|
||
static int ignore = register_signal_handlers(); | ||
}; // namespace | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters