From f0f3428d50416643ce685f1c3b47f8be4b7b2df7 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Jul 2026 09:37:47 +0100 Subject: [PATCH] fix: stop portal input capture thread on server exit Server aborted with "pure virtual method called" when the bind address was in use: EiScreen's PortalInputCapture glib thread outlived Arch and hit its freed vtable. ~EiScreen never deleted m_portalInputCapture, and a fatal startup threw past cleanupServer(). Fix both. --- src/lib/deskflow/ServerApp.cpp | 11 ++++++++++- src/lib/platform/EiScreen.cpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 2c22f7336..993c85230 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -516,7 +516,16 @@ int ServerApp::mainLoop() } // start server, etc - appUtil().startNode(); + try { + appUtil().startNode(); + } catch (...) { + // a fatal startup failure (e.g. the listen address is already in use) + // exits by throwing, which unwinds past the cleanup at the end of this + // function. tear the server down here so the screen and its worker + // threads don't outlive the app and call into freed globals on exit. + cleanupServer(); + throw; + } // handle hangup signal by reloading the server's configuration ARCH->setSignalHandler(Arch::ThreadSignal::Hangup, &reloadSignalHandler, nullptr); diff --git a/src/lib/platform/EiScreen.cpp b/src/lib/platform/EiScreen.cpp index 033c5e51e..db4cfadd0 100644 --- a/src/lib/platform/EiScreen.cpp +++ b/src/lib/platform/EiScreen.cpp @@ -94,6 +94,7 @@ EiScreen::~EiScreen() delete m_clipboard; delete m_portalRemoteDesktop; + delete m_portalInputCapture; } void EiScreen::eiLogEvent(ei_log_priority priority, const char *message) const