From 43d4fa9e883cb03239b3d578c9c57070f4fbd281 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 26 Jul 2026 23:32:29 -0700 Subject: [PATCH] crash: strip crash env and avoid leaking crash info fd on launch --- changelog/next.md | 1 + src/launch/main.cpp | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index 2b8215a..cb31dc1 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -11,3 +11,4 @@ - Fixed crashes when a wifi network disappear. - Fixed unhandled notifications sending `NotificationClosed` out of order. - Fixed `qs kill` not waiting for the process to exit. +- Fixed IPC calls from children of a crashed and relaunched process crashing. diff --git a/src/launch/main.cpp b/src/launch/main.cpp index efd6628..e97bb3c 100644 --- a/src/launch/main.cpp +++ b/src/launch/main.cpp @@ -27,20 +27,28 @@ namespace { void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) { #if CRASH_HANDLER auto lastInfoFdStr = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD"); + auto dumpPid = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt(); if (!lastInfoFdStr.isEmpty()) { auto lastInfoFd = lastInfoFdStr.toInt(); - QFile file; - if (!file.open(lastInfoFd, QFile::ReadOnly, QFile::AutoCloseHandle)) { - qFatal() << "Failed to open crash info fd. Cannot restart."; + RelaunchInfo info; + + { + QFile file; + if (!file.open(lastInfoFd, QFile::ReadOnly, QFile::AutoCloseHandle)) { + qFatal() << "Failed to open crash info fd. Cannot restart."; + } + + file.seek(0); + + auto ds = QDataStream(&file); + ds >> info; } - file.seek(0); - - auto ds = QDataStream(&file); - RelaunchInfo info; - ds >> info; + qunsetenv("__QUICKSHELL_CRASH_INFO_FD"); + qunsetenv("__QUICKSHELL_CRASH_DUMP_PID"); + qunsetenv("__QUICKSHELL_CRASH_SIGNAL"); LogManager::init( !info.noColor, @@ -50,8 +58,7 @@ void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) { info.logRules ); - qCritical().nospace() << "Quickshell has crashed under pid " - << qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt() + qCritical().nospace() << "Quickshell has crashed under pid " << dumpPid << " (Coredumps will be available under that pid.)"; qCritical() << "Further crash information is stored under"