Skip to content

Commit

Permalink
src: print backtrace on abort/unreachable code
Browse files Browse the repository at this point in the history
Print a C backtrace on fatal errors to make it easier to debug issues.

PR-URL: #6734
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
bnoordhuis authored and Fishrock123 committed Jul 5, 2016
1 parent 6cec90a commit c96d701
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,6 @@ static void OnFatalError(const char* location, const char* message) {
} else {
PrintErrorString("FATAL ERROR: %s\n", message);
}
DumpBacktrace(stderr);
fflush(stderr);
ABORT();
}
Expand Down
11 changes: 9 additions & 2 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ template <typename T> using remove_reference = std::remove_reference<T>;

// Windows 8+ does not like abort() in Release mode
#ifdef _WIN32
#define ABORT() raise(SIGABRT)
#define ABORT_NO_BACKTRACE() raise(SIGABRT)
#else
#define ABORT() abort()
#define ABORT_NO_BACKTRACE() abort()
#endif

#define ABORT() \
do { \
node::DumpBacktrace(stderr); \
fflush(stderr); \
ABORT_NO_BACKTRACE(); \
} while (0)

#if defined(NDEBUG)
# define ASSERT(expression)
# define CHECK(expression) \
Expand Down

0 comments on commit c96d701

Please sign in to comment.