summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-08-31 20:52:02 +0000
committerGitHub <noreply@github.com>2023-08-31 22:52:02 +0200
commit1a13d44d5dbe8e13480366dc97ea7eeee4ff42bb (patch)
tree8c11a21a711cb15f154418b4c61d7dbf07692cd8 /src
parentfc0c1896e097b3c3b2170ae69d38724e43960fe1 (diff)
refactor: raise SIGABRT instead of write to null address (#3124)
Diffstat (limited to 'src')
-rw-r--r--src/macros.hpp7
-rw-r--r--src/render/Renderer.cpp2
2 files changed, 5 insertions, 4 deletions
diff --git a/src/macros.hpp b/src/macros.hpp
index d14b6390..da80fc2f 100644
--- a/src/macros.hpp
+++ b/src/macros.hpp
@@ -3,6 +3,7 @@
#include "helpers/MiscFunctions.hpp"
#include "debug/Log.hpp"
#include <cmath>
+#include <csignal>
#include <utility>
#ifndef NDEBUG
@@ -57,9 +58,9 @@
if (!(expr)) { \
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \
getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \
- ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
+ ([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
- *((int*)nullptr) = 1; /* so that we crash and get a coredump */ \
+ raise(SIGABRT); \
}
#else
#define RASSERT(expr, reason, ...)
@@ -71,7 +72,7 @@
#define UNREACHABLE() \
{ \
Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \
- *((int*)nullptr) = 1; \
+ raise(SIGABRT); \
}
#else
#define UNREACHABLE() std::unreachable();
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index b6093676..8599f8df 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1973,7 +1973,7 @@ static int handleCrashLoop(void* data) {
g_pHyprRenderer->m_fCrashingDistort += 0.5f;
if (g_pHyprRenderer->m_fCrashingDistort >= 5.5f)
- *((int*)nullptr) = 1337;
+ raise(SIGABRT);
wl_event_source_timer_update(g_pHyprRenderer->m_pCrashingLoop, 1000);