summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-05-13 17:48:55 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2016-06-29 13:49:39 +0200
commite574f5b7008e43009a365b5535f49d39fcc020f5 (patch)
tree066c9ed98effe32c2aa5e2d571bc0ece93f7b5b8 /src
parent787eddf794921f095bfc33d774223a5c9e245e96 (diff)
downloadnode-new-e574f5b7008e43009a365b5535f49d39fcc020f5.tar.gz
src: print backtrace on abort/unreachable code
Print a C backtrace on fatal errors to make it easier to debug issues. PR-URL: https://github.com/nodejs/node/pull/6734 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc1
-rw-r--r--src/util.h11
2 files changed, 9 insertions, 3 deletions
diff --git a/src/node.cc b/src/node.cc
index 6d4c9fa160..eaf642b76a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -2398,7 +2398,6 @@ static void OnFatalError(const char* location, const char* message) {
} else {
PrintErrorString("FATAL ERROR: %s\n", message);
}
- DumpBacktrace(stderr);
fflush(stderr);
ABORT();
}
diff --git a/src/util.h b/src/util.h
index 94278e2b9f..f3f123c6d1 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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) \