https://bugs.kde.org/show_bug.cgi?id=528882

            Bug ID: 528882
           Summary: Akonadi crashes Kontact/KOrganizer when changing a
                    to-do date from the calendar view side pane
    Classification: Frameworks and Libraries
           Product: Akonadi
      Version First 6.8.3
       Reported In:
          Platform: openSUSE
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

Created attachment 198497
  --> https://bugs.kde.org/attachment.cgi?id=198497&action=edit
Patch

***
If you're not sure this is actually a bug or valid feature request, instead
post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see
https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
Do not paste LLM output.

Please remove this comment after reading and before submitting - thanks!
***

DESCRIPTION

Changing the date of a to-do from the to-do side pane in the calendar view can
reliably terminate Kontact or KOrganizer with an uncaught
`Akonadi::PayloadException`. The date is changed by right-clicking a to-do and
selecting a new date from the context menu. The failure has been reproduced
with several different to-do items. All affected database records have valid
Akonadi item IDs and the correct `application/x-vnd.akonadi.calendar.todo` MIME
type, so this does not appear to be persistent database corruption.

Immediately before each abort, the application logs:

Invalid mimetype requested: ""
terminate called after throwing an instance of 'Akonadi::PayloadException'
what(): Akonadi::PayloadException: Wrong Item payload type
(requested: sp(0)<QByteArray>;
 present: sp(2)<KCalendarCore::Incidence*>, itemId: <valid item id>)

Four consecutive reproductions involved four different valid item IDs. They
all belonged to the same DAV resource. Immediately before the payload error,
the journal also contains messages from the date-picker interaction.

STEPS TO REPRODUCE
1. Configure a CalDAV resource containing to-dos.
2. Open the calendar view in KOrganizer or Kontact.
3. Locate the to-do side pane next to the calendar.
4. Right-click a to-do in that side pane.
5. Use the context-menu action for changing the to-do date and select a date.
6. Repeat with another to-do if the first change does not trigger the timing
   condition.

OBSERVED RESULT

Jontact/KOrganizer aborts with `SIGABRT` due to an uncaught
`Akonadi::PayloadException`.


EXPECTED RESULT

The to-do date is changed without terminating the application. A transiently
missing MIME type in a cached item must not cause the generic payload
serializer to be selected for an already typed calendar payload.


SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a
terminal window):
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

Relevant backtrace:

#6  abort
#9  std::terminate()
#10 __cxa_throw
#11 libKPim6AkonadiCore.so.6
#12 libKPim6AkonadiCore.so.6
#13 Akonadi::ItemSerializerPlugin::apply(Akonadi::Item&, Akonadi::Item const&)
#14 Akonadi::Item::apply(Akonadi::Item const&)
#17 Akonadi::Monitor::itemChanged(Akonadi::Item const&, QSet<QByteArray>
const&)
#18 Akonadi::MonitorPrivate::emitItemsNotification(...)
#19 Akonadi::MonitorPrivate::emitNotification(...)
#20 Akonadi::MonitorPrivate::dispatchNotifications()
#21 Akonadi::MonitorPrivate::slotNotify(...)
#22 Akonadi::MonitorPrivate::handleCommands()

All four captured core dumps have the same relevant stack.

Versions:
Kontact:                 26.08.3-1.1
KOrganizer:              26.08.3-1.1
Akonadi:                 26.08.3-1.1
libKPim6AkonadiCore6:     26.08.3-1.1
Qt:                      6.12.0
KDE Frameworks:          6.31.0
Operating system:        openSUSE Tumbleweed
Session:                 Wayland

Analysis

`Item::apply()` currently checks MIME type and ID equality only with
`Q_ASSERT_X`. In release builds the assertion is disabled, so an item whose
target-side MIME type is temporarily empty continues into
`ItemSerializer::apply()`.

`ItemSerializer::apply()` selects the serializer using the target item:

TypePluginLoader::pluginForMimeTypeAndClass(
    item.mimeType(), item.availablePayloadMetaTypeIds());

With an empty target MIME type, Akonadi falls back to the generic serializer.
The incoming payload is already a `KCalendarCore::Incidence*`, producing the
observed `QByteArray` versus `Incidence*` mismatch.

Proposed fix:

When the target item has no MIME type but the incoming item has one,
`Item::apply()` should restore it before validating and applying the payload:

if (mimeType().isEmpty() && !other.mimeType().isEmpty()) {
    setMimeType(other.mimeType());
}

The complete patch, including an upstream-style regression test, is attached

Validation

The proposed patch was built against the official KDE `v26.08.3` Akonadi tag.
Results:

ItemTest: 12 passed, 0 failed
External public-API regression probe: passed
Repeated real-world date changes from the calendar to-do side pane: no crash

Without the patch, the external probe confirms that the target item's MIME type
remains empty after `Item::apply()`. With the patch, the MIME type and payload
are applied correctly.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to