diff options
-rw-r--r-- | src/common/Debugging/Errors.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp index f2da96b86bf..45f130ceb3b 100644 --- a/src/common/Debugging/Errors.cpp +++ b/src/common/Debugging/Errors.cpp @@ -23,13 +23,25 @@ #include <thread> #include <cstdarg> +/** + @file Errors.cpp + + @brief This file contains definitions of functions used for reporting critical application errors + + It is very important that (std::)abort is NEVER called in place of *((volatile int*)NULL) = 0; + Calling abort() on Windows does not invoke unhandled exception filters - a mechanism used by WheatyExceptionReport + to log crashes. exit(1) calls here are for static analysis tools to indicate that calling functions defined in this file + terminates the application. + */ + namespace Trinity { void Assert(char const* file, int line, char const* function, char const* message) { fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message); - abort(); + *((volatile int*)NULL) = 0; + exit(1); } void Assert(char const* file, int line, char const* function, char const* message, char const* format, ...) @@ -43,7 +55,8 @@ void Assert(char const* file, int line, char const* function, char const* messag fflush(stderr); va_end(args); - abort(); + *((volatile int*)NULL) = 0; + exit(1); } void Fatal(char const* file, int line, char const* function, char const* message) @@ -52,14 +65,16 @@ void Fatal(char const* file, int line, char const* function, char const* message file, line, function, message); std::this_thread::sleep_for(std::chrono::seconds(10)); - abort(); + *((volatile int*)NULL) = 0; + exit(1); } void Error(char const* file, int line, char const* function, char const* message) { fprintf(stderr, "\n%s:%i in %s ERROR:\n %s\n", file, line, function, message); - abort(); + *((volatile int*)NULL) = 0; + exit(1); } void Warning(char const* file, int line, char const* function, char const* message) @@ -72,7 +87,8 @@ void Abort(char const* file, int line, char const* function) { fprintf(stderr, "\n%s:%i in %s ABORTED\n", file, line, function); - abort(); + *((volatile int*)NULL) = 0; + exit(1); } } // namespace Trinity |