Fix a crash due to weird refcount messup during stack unwinding

Authored by dvratil on May 31 2019, 11:21 AM.

Description

Fix a crash due to weird refcount messup during stack unwinding

Summary:
My Akonadi Server has been crashing repeatadly whenever an exception was
thrown inside a handler. The crash was due to memory corruption when
stack unwinding caused the refcount of the "cmd" shared pointer to get
messed up which lead to double-free corruption.

The problem seems to be in the capture-by-value of the shared pointer in the
lambda, but I do not exactly understand what causes the problem, neither
was I able to produce a minimal reproducer case.

We can safely capture the shared pointer by reference, we don't keep a
reference to the functor anywhere.

Reviewers: KDE PIM, vkrause

Reviewed By: KDE PIM, vkrause

Subscribers: kde-pim

Tags: KDE PIM

Differential Revision: https://phabricator.kde.org/D21456

Details