Tuesday, September 20, 2022

Re: [patch] x11/krusader fix crash on exit

On 2022/09/20 18:44, Róbert Bagdán wrote:
> Hi!
>
> I noticed, that krusader segfaults when close. To reproduce, start
> krusader from terminal, and close with the close button.
>
> As I see it is the same issue what was on FreeBSD [1]. The fix is on
> upstream, but not released yet. I applied the patch, krusader builds
> on amd64 stable/current, however I just tested on stable 7.1, works
> fine, the segfault gone when close krusader.
>
> [1] https://invent.kde.org/utilities/krusader/-/commit/415d519e825a6b8b64d2ef5f9a8e9bf7a458d1d0

Makes sense to add this. Ports standard is to apply patches in the
patches/ directory, e.g.

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/krusader/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- Makefile 31 Mar 2022 16:38:32 -0000 1.43
+++ Makefile 20 Sep 2022 16:51:31 -0000
@@ -2,7 +2,7 @@ COMMENT= twin panel file manager for KDE

VERSION= 2.7.2
DISTNAME= krusader-${VERSION}
-REVISION= 1
+REVISION= 2

CATEGORIES= x11

Index: patches/patch-krusader_Panel_listpanel_cpp
===================================================================
RCS file: patches/patch-krusader_Panel_listpanel_cpp
diff -N patches/patch-krusader_Panel_listpanel_cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-krusader_Panel_listpanel_cpp 20 Sep 2022 16:51:31 -0000
@@ -0,0 +1,50 @@
+From 415d519e825a6b8b64d2ef5f9a8e9bf7a458d1d0 Mon Sep 17 00:00:00 2001
+From: Adriaan de Groot <groot@kde.org>
+Date: Mon, 19 Apr 2021 22:39:44 +0200
+Subject: [PATCH] Fix crash-on-exit on FreeBSD
+
+Scenario:
+- start krusader
+- close the application (alt-f4, or click the window-close button)
+- SEGV, with this (edited) backtrace:
+ #0 KUrlNavigator::editor (this=0x80a562400)
+ #1 0x000000000031e20e in ListPanel::eventFilter (this=0x80c2309c0, watched=0x80a6980d0, e=0x7fffffffc278)
+ #6 0x00000008018c3c0c in QWidget::~QWidget() () from /usr/local/lib/qt5/libQt5Widgets.so.5
+ #7 0x0000000800a26c4e in KUrlComboBox::~KUrlComboBox (this=0x80a6980d0)
+ #11 0x00000008005de60b in KUrlNavigator::~KUrlNavigator (this=0x80a562400)
+ #13 0x000000000031d5a5 in ListPanel::~ListPanel (this=0x80c2309c0)
+
+Analysis:
+- During the destructor, events are triggered, which hit the
+ event-filter function in the object that is undergoing destruction.
+ Since some of the objects referred to via pointer in the event-filter
+ are dead or being-destroyed, this is UB (so be glad it crashes!).
+- This is very similar to the problem and backtrace in KIO commit
+ a8a2c08014484145a4bd2a541a1cbeb8be856bf1.
+
+Fix:
+- Uninstall the event-filter before carrying on with destruction.
+- While here, add an extra nullptr check for the combobox in
+ the event-filter.
+
+Index: krusader/Panel/listpanel.cpp
+--- krusader/Panel/listpanel.cpp.orig
++++ krusader/Panel/listpanel.cpp
+@@ -379,6 +379,8 @@ ListPanel::ListPanel(QWidget *parent, AbstractPanelMan
+
+ ListPanel::~ListPanel()
+ {
++ view->widget()->removeEventFilter(this);
++ urlNavigator->editor()->removeEventFilter(this);
+ cancelProgress();
+ delete view;
+ view = 0;
+@@ -529,7 +531,7 @@ bool ListPanel::eventFilter(QObject * watched, QEvent
+ }
+ }
+ // handle URL navigator key events
+- else if(watched == urlNavigator->editor()) {
++ else if(urlNavigator && watched == urlNavigator->editor()) {
+ // override default shortcut for panel focus
+ if(e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);

No comments:

Post a Comment