Bug 377656

Summary: akonadiserver has an unhandled protocol exception
Product: [Frameworks and Libraries] Akonadi Reporter: Steve <sgrubb>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: bgodusky, dennis.schridde, dvratil, kde, mark, micuintus, mikemol, rdieter
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.6.1

Description Steve 2017-03-15 17:31:00 UTC
Kontact was in the process of checking my mail box and then akonadiserver crashed. This is the back trace from the core dump:

#0  0x00007fbbd3405765 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
        resultvar = 0
        pid = 3597
        selftid = 3757
#1  0x00007fbbd4aa94fe in KCrash::defaultCrashHandler(int) () at /lib64/libKF5Crash.so.5
#2  0x00007fbbd34057e0 in <signal handler called> () at /usr/lib64/libc-2.23.so
#3  0x00007fbbd3405765 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
        resultvar = 0
        pid = 3597
        selftid = 3757
#4  0x00007fbbd340736a in __GI_abort () at abort.c:89
        save_stage = 2
        act = 
          {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 0, 140444680092703, 140444683527456, 1, 140444683527587, 0, 18446744073709551615, 140444692594536, 140442175780560, 140442175780560, 1, 140444157013744, 140440800154128, 140444520413392, 140442175780608}}, sa_flags = -741075808, sa_restorer = 0x7fbaec001918}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#5  0x00007fbbd3d4452d in __gnu_cxx::__verbose_terminate_handler() () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
        terminating = true
        t = <optimized out>
#6  0x00007fbbd3d422d6 in __cxxabiv1::__terminate(void (*)()) (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:47
#7  0x00007fbbd3d42321 in std::terminate() () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:57
#8  0x00007fbbd3d42539 in __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*)) (obj=obj@entry=0x7fbaec015280, tinfo=0x55b315d71bc8 <typeinfo for Akonadi::ProtocolException>, 
    tinfo@entry=0x7fbbd480dc28 <typeinfo for Akonadi::ProtocolException>, dest=dest@entry=0x7fbbd45af7b0 <Akonadi::ProtocolException::~ProtocolException()>)
    at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:87
        globals = <optimized out>
#9  0x00007fbbd45cae42 in Akonadi::Protocol::DataStream::operator<< <unsigned char>(unsigned char) (this=<optimized out>, val=<optimized out>)
    at /usr/src/debug/akonadi-16.12.2/src/private/datastream_p_p.h:92
#10 0x00007fbbd45ce57f in Akonadi::Protocol::FetchItemsResponsePrivate::serialize(Akonadi::Protocol::DataStream&) const (stream=..., this=0x7fbaec021920)
    at /usr/src/debug/akonadi-16.12.2/src/private/protocol.cpp:266
#11 0x00007fbbd45ce57f in Akonadi::Protocol::FetchItemsResponsePrivate::serialize(Akonadi::Protocol::DataStream&) const (stream=..., this=0x7fbaec021920)
    at /usr/src/debug/akonadi-16.12.2/src/private/protocol.cpp:425
#12 0x00007fbbd45ce57f in Akonadi::Protocol::FetchItemsResponsePrivate::serialize(Akonadi::Protocol::DataStream&) const (this=0x7fbaec021920, stream=...)
    at /usr/src/debug/akonadi-16.12.2/src/private/protocol.cpp:3344
#13 0x00007fbbd45b5b14 in Akonadi::Protocol::serialize(QIODevice*, Akonadi::Protocol::Command const&) (command=..., stream=...)
    at /usr/src/debug/akonadi-16.12.2/src/private/protocol.cpp:383
        stream = {mDev = 0x7fbb140030d0, mWaitTimeout = 30000}
#14 0x00007fbbd45b5b14 in Akonadi::Protocol::serialize(QIODevice*, Akonadi::Protocol::Command const&) (device=<optimized out>, command=...)
    at /usr/src/debug/akonadi-16.12.2/src/private/protocol.cpp:636
        stream = {mDev = 0x7fbb140030d0, mWaitTimeout = 30000}
#15 0x000055b3159b2f33 in Akonadi::Server::Connection::sendResponse(long long, Akonadi::Protocol::Command const&) (this=0x55b317374a50, tag=1000, response=...) at /usr/src/debug/akonadi-16.12.2/src/server/connection.cpp:404
        stream = 
          {d = {d = 0x0}, dev = 0x7fbb140030d0, owndev = false, noswap = false, byteorder = QDataStream::BigEndian, ver = 17, q_status = QDataStream::WriteFailed}
#16 0x000055b3159b7412 in Akonadi::Server::Handler::failureResponse(QString const&) (response=..., this=0x7fbaec0151d0)
    at /usr/src/debug/akonadi-16.12.2/src/server/handler.cpp:268
        r = {<Akonadi::Protocol::Command> = {d_ptr = {d = 0x7fbaec021920}}, <No data fields>}
#17 0x000055b3159b7412 in Akonadi::Server::Handler::failureResponse(QString const&) (this=0x7fbaec0151d0, response=...)
    at /usr/src/debug/akonadi-16.12.2/src/server/handler.h:152
        r = {<Akonadi::Protocol::Command> = {d_ptr = {d = 0x7fbaec021920}}, <No data fields>}
#18 0x000055b3159b7412 in Akonadi::Server::Handler::failureResponse(QString const&) (this=this@entry=0x7fbaec0151d0, failureMessage=...)
    at /usr/src/debug/akonadi-16.12.2/src/server/handler.cpp:261
        r = {<Akonadi::Protocol::Command> = {d_ptr = {d = 0x7fbaec021920}}, <No data fields>}
#19 0x000055b3159b75cf in Akonadi::Server::Handler::failureResponse(char const*) (this=0x7fbaec0151d0, failureMessage=<optimized out>)
    at /usr/src/debug/akonadi-16.12.2/src/server/handler.cpp:252
#20 0x000055b3159b4f33 in Akonadi::Server::Connection::slotNewData() (this=0x55b317374a50) at /usr/src/debug/akonadi-16.12.2/src/server/connection.cpp:252
        e = <optimized out>
        stream = 
          {d = {d = 0x0}, dev = 0x7fbb140030d0, owndev = false, noswap = false, byteorder = QDataStream::BigEndian, ver = 17, q_status = QDataStream::Ok}
        tag = 1000
        cmd = {d_ptr = {d = 0x7fbb14010180}}
        currentCommand = {static null = {<No data fields>}, d = 0x7fbbd433c620 <QArrayData::shared_null>}
#21 0x00007fbbd42a715c in QMetaObject::activate(QObject*, int, int, void**) (a=0x7fbb3dffa8a0, r=0x55b317374a50, this=<optimized out>)
    at ../../src/corelib/kernel/qobject_impl.h:124
        obj = {d = 0x7fbb14003c90}
        receiverInSameThread = <optimized out>
        sw = {receiver = 0x55b317374a50, previousSender = 0x0, currentSender = {sender = 0x7fbb140030d0, signal = 3, ref = 1}, switched = true}
        callFunction = <optimized out>
        receiver = 0x55b317374a50
        method_relative = <optimized out>
        c = 0x7fbb14003cc0
        last = 0x7fbb14003cc0
        locker = {val = 140444697358024}
        connectionLists = {connectionLists = 0x7fbb14003d10}
        list = 0x7fbb14003e08
        signal_index = 3
        empty_argv = {0x0}
        currentThreadId = 0x7fbb3dffb700

The version is kf5-akonadi-server-16.12.2-1.fc24.x86_64
Comment 1 Dennis Schridde 2017-03-20 13:33:37 UTC
Duplicate of bug #374734?
Comment 2 Steve 2017-03-20 18:28:54 UTC
I think this is different because its dying via an abort() call. They are usually placed in code to stop a program when its doing something that violates some expectation. The idea is to force a coredump to collect a backtrace to get an idea of what's wrong.

At line 8 the code throws a protocol exception and this probably comes near the code mentioned in line 9. So, something unexpected in the imap protocol is probably causing the issue.
Comment 3 Dennis Schridde 2017-03-21 09:06:16 UTC
DrKonqi suggested both bugs, this and duplicates of the other, as possible duplicates of a crash that I was experiencing. I assumed that was because the backtrace was the same.
Comment 4 Steve 2017-03-21 18:23:35 UTC
In src/server/connection.cpp at line 404, there should probably be a try/catch around the Protocol::serialize() call:

void Connection::sendResponse(qint64 tag, const Protocol::Command &response)
{
    if (Tracer::self()->currentTracer() != QLatin1String("null")) {
        Tracer::self()->connectionOutput(m_identifier, QByteArray::number(tag) + ' ' + response.debugString().toUtf8());
    }
    QDataStream stream(m_socket);
    stream << tag;
    Protocol::serialize(m_socket, response);
}

because way down at the bottom in src/private/datastream_p_p.h at line 92, we find:

    if (mDev->write((char *)&val, sizeof(T)) != sizeof(T)) {
        throw Akonadi::ProtocolException("Failed to write data to stream");
    }

Does this help?
Comment 5 Daniel Vrátil 2017-03-22 00:43:51 UTC
*** Bug 377871 has been marked as a duplicate of this bug. ***
Comment 6 Steve 2017-03-22 01:36:24 UTC
Some information printed to the console around the time of another abort:

org.kde.pim.akonadicore: Got a stale notification for an item which was already removed. 2061954 ""
org.kde.pim.akonadicore: Got a stale notification for an item which was already removed. 2061955 ""
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-cmd.socket"
org.kde.pim.akonadicore: Socket error occurred: "QLocalSocket: Remote closed"
org.kde.pim.akonadicore: Error on fetching collection statistics:  ""
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-cmd.socket"
org.kde.pim.akonadicore: Socket error occurred: "QLocalSocket: Remote closed"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
org.kde.pim.akonadicore: "QLocalSocket: Remote closed" "/tmp/akonadi-sgrubb.jJx32f/akonadiserver-ntf.socket"
"Unknown error."
org.kde.pim.akonadicore: Error on fetching collection statistics:  ""
"Unknown error."
org.kde.pim.akonadicore: Error on fetching collection statistics:  ""
Comment 7 Daniel Vrátil 2017-04-01 10:32:09 UTC
Git commit da7070a7facb3c2f91c03b28c36ba5b929b89a42 by Daniel Vrátil.
Committed on 01/04/2017 at 10:31.
Pushed by dvratil into branch 'Applications/17.04'.

Handle nested exceptions during error handling
FIXED-IN: 5.6.1

M  +30   -4    src/server/connection.cpp

https://commits.kde.org/akonadi/da7070a7facb3c2f91c03b28c36ba5b929b89a42
Comment 8 Daniel Vrátil 2017-04-18 22:10:43 UTC
*** Bug 378766 has been marked as a duplicate of this bug. ***
Comment 9 Christoph Feck 2017-06-13 16:19:31 UTC
*** Bug 380394 has been marked as a duplicate of this bug. ***
Comment 10 Christoph Feck 2018-02-14 14:30:20 UTC
*** Bug 382439 has been marked as a duplicate of this bug. ***
Comment 11 Christoph Feck 2018-02-14 14:30:30 UTC
*** Bug 389500 has been marked as a duplicate of this bug. ***