aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Collision/Management/MMapManager.cpp2
-rw-r--r--src/common/Common.h1
-rw-r--r--src/common/Debugging/Errors.cpp19
-rw-r--r--src/common/Debugging/Errors.h4
-rw-r--r--src/common/Utilities/Util.h2
5 files changed, 26 insertions, 2 deletions
diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp
index a5685c65d9c..00985e4fa1d 100644
--- a/src/common/Collision/Management/MMapManager.cpp
+++ b/src/common/Collision/Management/MMapManager.cpp
@@ -230,7 +230,7 @@ namespace MMAP
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
// we cannot recover from this error - assert out
TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
- ASSERT(false);
+ ABORT();
}
else
{
diff --git a/src/common/Common.h b/src/common/Common.h
index 09d64acc795..4c209f89ec8 100644
--- a/src/common/Common.h
+++ b/src/common/Common.h
@@ -39,6 +39,7 @@
#include <sstream>
#include <algorithm>
#include <memory>
+#include <vector>
#include "Debugging/Errors.h"
diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp
index cebd9d4cf2f..45f130ceb3b 100644
--- a/src/common/Debugging/Errors.cpp
+++ b/src/common/Debugging/Errors.cpp
@@ -23,6 +23,17 @@
#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)
@@ -72,4 +83,12 @@ void Warning(char const* file, int line, char const* function, char const* messa
file, line, function, message);
}
+void Abort(char const* file, int line, char const* function)
+{
+ fprintf(stderr, "\n%s:%i in %s ABORTED\n",
+ file, line, function);
+ *((volatile int*)NULL) = 0;
+ exit(1);
+}
+
} // namespace Trinity
diff --git a/src/common/Debugging/Errors.h b/src/common/Debugging/Errors.h
index 4d4624b63dd..edf56b29136 100644
--- a/src/common/Debugging/Errors.h
+++ b/src/common/Debugging/Errors.h
@@ -29,6 +29,8 @@ namespace Trinity
DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
+
+ DECLSPEC_NORETURN void Abort(char const* file, int line, char const* function) ATTR_NORETURN;
void Warning(char const* file, int line, char const* function, char const* message);
@@ -46,8 +48,10 @@ namespace Trinity
#define WPFatal(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
+#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
#define ASSERT WPAssert
+#define ABORT WPAbort
template <typename T> inline T* ASSERT_NOTNULL(T* pointer)
{
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 3da1c800410..6a872b44a60 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -537,7 +537,7 @@ bool CompareValues(ComparisionType type, T val1, T val2)
return val1 <= val2;
default:
// incorrect parameter
- ASSERT(false);
+ ABORT();
return false;
}
}