summaryrefslogtreecommitdiff
path: root/user/trojita/segfault-sorting-mailboxes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/trojita/segfault-sorting-mailboxes.patch')
-rw-r--r--user/trojita/segfault-sorting-mailboxes.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/user/trojita/segfault-sorting-mailboxes.patch b/user/trojita/segfault-sorting-mailboxes.patch
new file mode 100644
index 000000000..833110983
--- /dev/null
+++ b/user/trojita/segfault-sorting-mailboxes.patch
@@ -0,0 +1,72 @@
+From d4e01b6b2cf476f4892b24bdeaae67f5b9ed2ee2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jkt@kde.org>
+Date: Tue, 1 Feb 2022 21:04:14 +0100
+Subject: [PATCH] MailboxNameComparator: implement "less than", not "less or
+ equal"
+
+This comparator is used for "natural order" sorting of mailboxes. The
+usual way of sorting is via a functor which satisfies the Compare [1]
+C++ named requirement, which is effectively a "less than" operation.
+This code implemented a less-than-or-equal, which means that it was not
+usable for `std::sort` which would segfault:
+
+ 0x00007ffff354a35d in __dynamic_cast () from /nix/store/b0p7nvkwxr65q016zsqicrd4bcg5bv1s-gcc-10.3.0-lib/lib/libstdc++.so.6
+ (gdb) bt
+ #0 0x00007ffff354a35d in __dynamic_cast () from /nix/store/b0p7nvkwxr65q016zsqicrd4bcg5bv1s-gcc-10.3.0-lib/lib/libstdc++.so.6
+ #1 0x00000000005d316c in (anonymous namespace)::MailboxNameComparator (a=0x520041004d005c, b=0x12ac740) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:74
+ #2 0x00000000005e1d46 in __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)>::operator()<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator> (__it2=..., __it1=..., this=<synthetic pointer>) at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1909
+ #3 std::__unguarded_partition<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> > (__comp=..., __pivot=..., __last=..., __first=...)
+ at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1909
+ #4 std::__unguarded_partition_pivot<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> > (__comp=..., __last=..., __first=...)
+ at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1931
+ #5 std::__introsort_loop<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, int, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> > (__first=..., __last=...,
+ __depth_limit=<optimized out>, __depth_limit@entry=9, __comp=__comp@entry=...) at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1962
+ #6 0x00000000005e1db8 in std::__introsort_loop<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, int, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> > (__first=..., __last=...,
+ __depth_limit=<optimized out>, __depth_limit@entry=10, __comp=__comp@entry=...) at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1964
+ #7 0x00000000005dd6fd in std::__sort<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> > (__comp=..., __last=..., __first=...)
+ at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:1979
+ #8 std::sort<QTypedArrayData<Imap::Mailbox::TreeItem*>::iterator, bool (*)(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)> (__first=..., __last=..., __first=..., __last=...,
+ __comp=0x5d3130 <(anonymous namespace)::MailboxNameComparator(Imap::Mailbox::TreeItem const*, Imap::Mailbox::TreeItem const*)>) at /nix/store/v819nrv8d33ns36gm4v9vqydq1v95axi-gcc-10.3.0/include/c++/10.3.0/bits/stl_algo.h:4899
+ #9 Imap::Mailbox::Model::finalizeList (this=0xbfbdb0, parser=<optimized out>, mailboxPtr=0x7ffffffe4438) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:352
+ #10 0x000000000061d512 in Imap::Mailbox::ListChildMailboxesTask::handleStateHelper (this=0x124d790, resp=0x124e840) at /home/jkt/work/prog/trojita/src/Imap/Tasks/ListChildMailboxesTask.cpp:96
+ #11 0x00000000005deadc in Imap::Mailbox::Model::responseReceived (this=0xbfbdb0, it=...) at /home/jkt/work/prog/trojita/src/Imap/Model/Model.cpp:220
+ #12 0x00007ffff396918c in QObject::event(QEvent*) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #13 0x00007ffff441776f in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Widgets.so.5
+ #14 0x00007ffff393c40a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #15 0x00007ffff393f451 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #16 0x00007ffff3994d93 in ?? () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #17 0x00007ffff1883aab in g_main_context_dispatch () from /nix/store/1qiv23m1q9fk18rwkzrk29ciz87030lp-glib-2.70.1/lib/libglib-2.0.so.0
+ #18 0x00007ffff1883d58 in g_main_context_iterate.constprop () from /nix/store/1qiv23m1q9fk18rwkzrk29ciz87030lp-glib-2.70.1/lib/libglib-2.0.so.0
+ #19 0x00007ffff1883e0f in g_main_context_iteration () from /nix/store/1qiv23m1q9fk18rwkzrk29ciz87030lp-glib-2.70.1/lib/libglib-2.0.so.0
+ #20 0x00007ffff39943f0 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #21 0x00007ffff393adab in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #22 0x00007ffff39433a0 in QCoreApplication::exec() () from /nix/store/fwc2c76yqyyj0pj6abvsyzlgd2r1rvr0-qtbase-5.15.3/lib/libQt5Core.so.5
+ #23 0x000000000047fafb in main (argc=<optimized out>, argv=0x7ffffffe4b80) at /home/jkt/work/prog/trojita/src/Gui/main.cpp:205
+
+[1] https://en.cppreference.com/w/cpp/named_req/Compare
+
+Change-Id: Ib88e377fafc94de7160c63832c8115756d360732
+---
+ src/Imap/Model/Model.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/Imap/Model/Model.cpp b/src/Imap/Model/Model.cpp
+index 79e34658..1d539e22 100644
+--- a/src/Imap/Model/Model.cpp
++++ b/src/Imap/Model/Model.cpp
+@@ -76,10 +76,10 @@ bool MailboxNameComparator(const TreeItem *const a, const TreeItem *const b)
+ const TreeItemMailbox *const mailboxB = dynamic_cast<const TreeItemMailbox *const>(b);
+
+ if (mailboxA->mailbox() == QLatin1String("INBOX"))
+- return true;
++ return mailboxB->mailbox() != QLatin1String("INBOX");
+ if (mailboxB->mailbox() == QLatin1String("INBOX"))
+ return false;
+- return mailboxA->mailbox().compare(mailboxB->mailbox(), Qt::CaseInsensitive) < 1;
++ return mailboxA->mailbox().compare(mailboxB->mailbox(), Qt::CaseInsensitive) < 0;
+ }
+
+ bool uidComparator(const TreeItem *const item, const uint uid)
+--
+GitLab
+