Bug 261069 - deskutils/korganizer: Crashes with Segmentation fault (11) edit existing calendar entry
Summary: deskutils/korganizer: Crashes with Segmentation fault (11) edit existing cale...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-kde (group)
URL: https://bugs.kde.org/show_bug.cgi?id=...
Keywords: crash, needs-patch, needs-qa, regression
Depends on:
Blocks:
 
Reported: 2022-01-10 02:03 UTC by Greg Rivers
Modified: 2022-01-27 16:49 UTC (History)
2 users (show)

See Also:
tcberner: maintainer-feedback+
koobs: merge-quarterly?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Rivers 2022-01-10 02:03:39 UTC
13.0-RELEASE-p5
kde5 installed from "latest" pkg repo

Since the kde5 5.23.4.21.08.3 -> 5.23.4.21.12.0 update in mid December last month, korganizer seg faults every time I attempt to edit an existing calendar entry. This happens when run from within kontact as well. The KDE crash handler reports:

Executable: kontact PID: 61430 Signal: Segmentation fault (11) Time: 9 Jan 2022 17:31:42 CST

This happens 100% of the time. Intermittently, kontact crashes on exit too.

Today's kde5 5.23.5.21.12.0 -> 5.23.5.21.12.1 update did not help.
Comment 1 Greg Rivers 2022-01-20 20:58:52 UTC
The kf5 update 5.89.0 -> 5.90.0 did not help either. Does no one else run kontact/korganaizer? Or am I the only one seeing this crash?
Comment 2 Tobias C. Berner freebsd_committer freebsd_triage 2022-01-21 04:21:09 UTC
Moin moin 

Indeed, there seems to be a segfault in kldap when creating new entries here too.

mfg Tobias
Comment 3 Tobias C. Berner freebsd_committer freebsd_triage 2022-01-21 04:34:58 UTC
* thread #1, name = 'korganizer', stop reason = signal SIGSEGV: invalid address (fault address: 0x20)
    frame #0: 0x0000000803ad4ad0 libKF5Ldap.so.5`QWeakPointer<QObject>::internalData(this=0x0000000000000020) const at qsharedpointer_impl.h:698:18
   695      // a weak pointer's data but the weak pointer itself
   696      inline T *internalData() const noexcept
   697      {
-> 698          return d == nullptr || d->strongref.loadRelaxed() == 0 ? nullptr : value;
   699      }
   700
   701      Data *d;
Comment 4 Adriaan de Groot freebsd_committer freebsd_triage 2022-01-23 17:08:16 UTC
- start korganizer (I'm not sure I've ever done that before)
- click "New Event"

```
[KCrash Handler]
#7  0x0000000802fac745 in  () at /usr/local/lib/libKF5Ldap.so.5
#8  0x0000000802faaff1 in KLDAP::LdapClient::~LdapClient() () at /usr/local/lib/libKF5Ldap.so.5
#9  0x0000000803a3127b in  () at /usr/local/lib/libKF5IncidenceEditor.so.5
#10 0x0000000803a2ae93 in IncidenceEditorNG::ResourceManagement::ResourceManagement(QWidget*) () at /usr/local/lib/libKF5IncidenceEditor.so.5
#11 0x0000000803a13c27 in  () at /usr/local/lib/libKF5IncidenceEditor.so.5
#12 0x0000000803a38529 in  () at /usr/local/lib/libKF5IncidenceEditor.so.5
#13 0x0000000803a3d899 in IncidenceEditorNG::IncidenceDialog::IncidenceDialog(Akonadi::IncidenceChanger*, QWidget*, QFlags<Qt::WindowType>) () at /usr/local/lib/libKF5IncidenceEditor.so.5
#14 0x0000000803a3791d in IncidenceEditorNG::IncidenceDialogFactory::create(bool, KCalendarCore::IncidenceBase::IncidenceType, Akonadi::IncidenceChanger*, QWidget*, QFlags<Qt::WindowType>) () at /usr/local/lib/libKF5IncidenceEditor.so.5
```

Since I don't have a clue what kind of backend -- if any -- is even configured for KO, I do wonder why there would be an LDAP connection to deal with. Running this in valgrind gets me a similar BT with no suggestion of memory corruption before the crash.
Comment 5 Greg Rivers 2022-01-23 23:44:27 UTC
(In reply to Adriaan de Groot from comment #4)
I think the default backend for calendars is either the "iCal Calendar File" or the "iCal Calendar Folder" resource. I'm using the "DAV groupware" CalDav resource, as my calendars are stored on a Nextcloud instance. Apparently the crash occurs with any backend. I too am surprised to see LDAP dependencies for calendars.

Additionally, I can confirm that besides editing existing calendar entries, attempting to create a new one by clicking "New Event" also crashes korganizer. I ordinarily create new events using kmail's "Accept" function when I receive calendar invitations in email; new events created that way do not crash korganizer.
Comment 6 Adriaan de Groot freebsd_committer freebsd_triage 2022-01-24 00:32:12 UTC
I have a fix, but no energy this evening to upstream it and add it to ports. It goes in kldap, not korganizer itself, if you want to try it yourself.

--- src/widgets/ldapclient.cpp
+++ src/widgets/ldapclient.cpp
@@ -31,9 +31,11 @@ public:
 
     ~LdapClientPrivate()
     {
-        q->cancelQuery();
+        cancelQuery();
     }
 
+    void cancelQuery();
+    
     void startParseLDIF();
     void parseLDIF(const QByteArray &data);
     void endParseLDIF();
@@ -133,12 +135,17 @@ void LdapClient::startQuery(const QString &filter)
 
 void LdapClient::cancelQuery()
 {
-    if (d->mJob) {
-        d->mJob->kill();
-        d->mJob = nullptr;
+    d->cancelQuery();
+}
+
+void LdapClient::LdapClientPrivate::cancelQuery()
+{
+    if (mJob) {
+        mJob->kill();
+        mJob = nullptr;
     }
 
-    d->mActive = false;
+    mActive = false;
 }
 
 void LdapClient::LdapClientPrivate::slotData(KIO::Job *, const QByteArray &data)
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-01-24 13:12:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=acbc052765d87af0a436f10b4c5a35880eaa14d2

commit acbc052765d87af0a436f10b4c5a35880eaa14d2
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2022-01-24 11:02:08 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2022-01-24 13:12:01 +0000

    net/kldap: fix crash because of UB

    Patch submitted upstream.

    PR:     261069

 net/kldap/Makefile                  |  1 +
 net/kldap/files/patch-UB.diff (new) | 68 +++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
Comment 8 commit-hook freebsd_committer freebsd_triage 2022-01-24 13:15:25 UTC
A commit in branch 2022Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=017b38ede362a0ce60b109b4756f6924572df820

commit 017b38ede362a0ce60b109b4756f6924572df820
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2022-01-24 11:02:08 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2022-01-24 13:14:27 +0000

    net/kldap: fix crash because of UB

    Patch submitted upstream.

    PR:     261069
    (cherry picked from commit acbc052765d87af0a436f10b4c5a35880eaa14d2)

 net/kldap/Makefile                  |  1 +
 net/kldap/files/patch-UB.diff (new) | 68 +++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
Comment 9 Adriaan de Groot freebsd_committer freebsd_triage 2022-01-24 13:15:58 UTC
Landed in main and quarterly. I tested it in main, at least: korganizer does not crash when I click the "New Event" button.
Comment 10 Greg Rivers 2022-01-27 16:49:18 UTC
After 'pkg[67186]: kldap upgraded: 21.12.1 -> 21.12.1_1' today, I'm happy to report that all is well again. Thanks so much for finding and fixing the problem so quickly.