generate coredumps on sigabrt too

This commit is contained in:
Vaxry 2023-03-01 15:08:44 +00:00
parent 7c5c7ced91
commit 6c250df77e
3 changed files with 8 additions and 6 deletions

View file

@ -18,14 +18,14 @@ int handleCritSignal(int signo, void* data) {
return 0; // everything went fine return 0; // everything went fine
} }
void handleSegv(int sig) { void handleUnrecoverableSignal(int sig) {
if (g_pHookSystem->m_bCurrentEventPlugin) { if (g_pHookSystem->m_bCurrentEventPlugin) {
longjmp(g_pHookSystem->m_jbHookFaultJumpBuf, 1); longjmp(g_pHookSystem->m_jbHookFaultJumpBuf, 1);
return; return;
} }
CrashReporter::createAndSaveCrash(); CrashReporter::createAndSaveCrash(sig);
abort(); abort();
} }
@ -74,7 +74,8 @@ CCompositor::CCompositor() {
// register crit signal handler // register crit signal handler
wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr); wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr);
signal(SIGSEGV, handleSegv); signal(SIGSEGV, handleUnrecoverableSignal);
signal(SIGABRT, handleUnrecoverableSignal);
//wl_event_loop_add_signal(m_sWLEventLoop, SIGINT, handleCritSignal, nullptr); //wl_event_loop_add_signal(m_sWLEventLoop, SIGINT, handleCritSignal, nullptr);
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay, &m_sWLRSession); m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay, &m_sWLRSession);

View file

@ -3,6 +3,7 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#include <execinfo.h> #include <execinfo.h>
#include <fstream> #include <fstream>
#include <signal.h>
#include "../plugins/PluginSystem.hpp" #include "../plugins/PluginSystem.hpp"
@ -33,7 +34,7 @@ std::string getRandomMessage() {
return MESSAGES[distribution(engine)]; return MESSAGES[distribution(engine)];
} }
void CrashReporter::createAndSaveCrash() { void CrashReporter::createAndSaveCrash(int sig) {
// get the backtrace // get the backtrace
const int PID = getpid(); const int PID = getpid();
@ -43,7 +44,7 @@ void CrashReporter::createAndSaveCrash() {
finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n"; finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n";
finalCrashReport += getRandomMessage() + "\n\n"; finalCrashReport += getRandomMessage() + "\n\n";
finalCrashReport += "Hyprland received signal 11 (SIGSEGV): Segmentation Fault\n\n"; finalCrashReport += getFormat("Hyprland received signal %d (%s): Segmentation Fault\n\n", sig, strsignal(sig));
if (!g_pPluginSystem->getAllPlugins().empty()) { if (!g_pPluginSystem->getAllPlugins().empty()) {
finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n"; finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n";

View file

@ -3,5 +3,5 @@
#include "../defines.hpp" #include "../defines.hpp"
namespace CrashReporter { namespace CrashReporter {
void createAndSaveCrash(); void createAndSaveCrash(int sig);
}; };