[Interest] QDBusConnection::sessionBus() : caching required?

René J.V. Bertin rjvbertin at gmail.com
Tue May 31 21:27:59 CEST 2016


Hi,

I had a crash in QDBusConnection::sessionBus() earlier today, called from a dtor in a style plugin. The traceback showed a NULL "this" pointer (frame #12):

    frame #4: 0x00007fff8b9035aa libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x000000010a30b15f QtCore`QMutex::lock() [inlined] std::__1::__atomic_base<QMutexData*, false>::compare_exchange_strong(__m=<unavailable>) + 1 at atomic:622
    frame #6: 0x000000010a30b15e QtCore`QMutex::lock() [inlined] bool QAtomicOps<QMutexData*>::testAndSetAcquire<QMutexData*>(std::__1::atomic<QMutexData*>&, QMutexData*, QMutexData*, QMutexData**) at qatomic_cxx11.h:158
    frame #7: 0x000000010a30b15e QtCore`QMutex::lock() [inlined] QBasicAtomicPointer<QMutexData>::testAndSetAcquire(QMutexData*, QMutexData*, QMutexData*&) at qbasicatomic.h:276
    frame #8: 0x000000010a30b15e QtCore`QMutex::lock() [inlined] QBasicMutex::fastTryLock(QMutexData*&) at qmutex.h:82
    frame #9: 0x000000010a30b15e QtCore`QMutex::lock(this=0x0000000000000020) + 14 at qmutex.cpp:219
    frame #10: 0x0000000108b60f31 QtDBus`QDBusConnectionManager::busConnection(QDBusConnection::BusType) [inlined] QMutexLocker::QMutexLocker(m=0x0000000000000020) + 81 at qmutex.h:128
    frame #11: 0x0000000108b60f29 QtDBus`QDBusConnectionManager::busConnection(QDBusConnection::BusType) [inlined] QMutexLocker::QMutexLocker(m=0x0000000000000020) at qmutex.h:131
    frame #12: 0x0000000108b60f29 QtDBus`QDBusConnectionManager::busConnection(this=0x0000000000000000, type=SessionBus) + 73 at qdbusconnection.cpp:116
    frame #13: 0x0000000108b63878 QtDBus`QDBusConnection::sessionBus() + 24 at qdbusconnection.cpp:1180

the dtor cannot do a double disconnect or something of the sort as far as I can see. It does however do

auto bus = QDBusConnection::sessionBus();

just like the ctor does when setting up DBus. Is that correct practice or should one somehow cache the result of sessionBus() in order to call it only once?

This is Qt 5.6, btw.

Thanks,
R.



More information about the Interest mailing list