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

René J. V. Bertin rjvbertin at gmail.com
Wed Jun 1 00:07:18 CEST 2016


Thiago Macieira wrote:

> You can call multiple times and you'll always get the same connection.

OK, thanks.

Here's another observation (& backtrace) potentially to be taken into account 
for your fix: when I don't get a crash-on-exit I often get a deadlock like so:

  * frame #0: 0x00007fff85129716 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff8af34c3b libsystem_pthread.dylib`_pthread_cond_wait + 
727
    frame #2: 0x0000000112abc77b 
QtCore`QWaitConditionPrivate::wait(this=0x00007fda59e5a300, time=<unavailable>) 
+ 75 at qwaitcondition_unix.cpp:136
    frame #3: 0x0000000112abc62b 
QtCore`QWaitCondition::wait(this=0x00007fda59e517d8, mutex=0x00007fda59e517d0, 
time=18446744073709551615) + 155 at qwaitcondition_unix.cpp:208
    frame #4: 0x0000000112ab683f 
QtCore`QSemaphore::acquire(this=0x00007fff50614d38, n=1) + 79 at 
qsemaphore.cpp:137
    frame #5: 0x0000000112cadc13 
QtCore`QMetaObject::activate(sender=0x00007fda59c56500, 
signalOffset=<unavailable>, local_signal_index=<unavailable>, 
argv=<unavailable>) + 2499 at qobject.cpp:3698
    frame #6: 0x000000011134f280 
QtDBus`QDBusConnectionPrivate::signalNeedsDisconnecting(this=<unavailable>, 
_t1=<unavailable>, _t2=<unavailable>) + 64 at moc_qdbusconnection_p.cpp:345
    frame #7: 0x00000001113135ff 
QtDBus`QDBusConnectionPrivate::disconnectSignal(this=0x00007fda59c56500, 
service=<unavailable>, path=<unavailable>, interface=<unavailable>, 
name=<unavailable>, argumentMatch=<unavailable>, signature=<unavailable>, 
receiver=<unavailable>, slot=<unavailable>) + 287 at qdbusintegrator.cpp:2188
    frame #8: 0x00000001113008fb QtDBus`QDBusConnection::disconnect(QString 
const&, QString const&, QString const&, QString const&, QObject*, char const*) 
[inlined] QStringList::QStringList(this=0x0000000112eed470, 
this=0x0000000112eed470, this=0x0000000112eecc30, this=0x0000000112eecc30, 
argumentMatch=0x0000000112eed470, signature=0x0000000112eecc30, 
receiver=<unavailable>) + 158 at qdbusconnection.cpp:864
    frame #9: 0x000000011130085d 
QtDBus`QDBusConnection::disconnect(this=0x00007fda5c51b9e0, 
service=0x00007fff50614ff8, path=0x00007fff50614ff0, 
interface=0x00007fff50614fe8, name=0x00007fff50614fe0, 
receiver=0x00007fda5a191000, slot=0x000000011f0532d8) + 29 at 
qdbusconnection.cpp:822
    frame #10: 0x000000011eff0e88 
qtcurve.so`QtCurve::Style::disconnectDBus(this=0x00007fda5a191000) + 168 at 
qtcurve.cpp:712
    frame #11: 0x000000011f029e96 
qtcurve.so`QtCurve::StylePlugin::~StylePlugin() [inlined] 
QtCurve::runAllCleanups() + 13 at qtcurve_plugin.cpp:86
    frame #12: 0x000000011f029e89 
qtcurve.so`QtCurve::StylePlugin::~StylePlugin() [inlined] 
QtCurve::StylePlugin::~StylePlugin(this=<unavailable>) + 16 at 
qtcurve_plugin.cpp:167
    frame #13: 0x000000011f029e79 
qtcurve.so`QtCurve::StylePlugin::~StylePlugin() [inlined] 
QtCurve::StylePlugin::~StylePlugin(this=<unavailable>) at qtcurve_plugin.cpp:166
    frame #14: 0x000000011f029e79 
qtcurve.so`QtCurve::StylePlugin::~StylePlugin(this=<unavailable>) + 9 at 
qtcurve_plugin.cpp:166
    frame #15: 0x0000000112c6e24d 
QtCore`QLibraryPrivate::unload(this=0x00007fda59e51230, flag=NoUnloadSys) + 93 
at qlibrary.cpp:551
    frame #16: 0x0000000112c66d48 
QtCore`QFactoryLoaderPrivate::~QFactoryLoaderPrivate(this=0x00007fda59e50ca0) + 
88 at qfactoryloader.cpp:88
    frame #17: 0x0000000112c6714e 
QtCore`QFactoryLoaderPrivate::~QFactoryLoaderPrivate() [inlined] 
QFactoryLoaderPrivate::~QFactoryLoaderPrivate(this=0x00007fda59e50ca0) + 14 at 
qfactoryloader.cpp:85
    frame #18: 0x0000000112c67149 
QtCore`QFactoryLoaderPrivate::~QFactoryLoaderPrivate(this=0x00007fda59e50ca0) + 
9 at qfactoryloader.cpp:85
    frame #19: 0x0000000112ca5801 QtCore`QObject::~QObject() [inlined] 
QScopedPointerDeleter<QObjectData>::cleanup(pointer=<unavailable>) + 2033 at 
qscopedpointer.h:54
    frame #20: 0x0000000112ca57f6 QtCore`QObject::~QObject() [inlined] 
QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> 
>::~QScopedPointer() + 4 at qscopedpointer.h:101
    frame #21: 0x0000000112ca57f2 QtCore`QObject::~QObject() [inlined] 
QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> 
>::~QScopedPointer() at qscopedpointer.h:99
    frame #22: 0x0000000112ca57f2 QtCore`QObject::~QObject(this=<unavailable>) + 
2018 at qobject.cpp:1042
    frame #23: 0x0000000112c6928e QtCore`QFactoryLoader::~QFactoryLoader() 
[inlined] QFactoryLoader::~QFactoryLoader(this=0x00007fda59e2a3a0) + 14 at 
qfactoryloader.cpp:227
    frame #24: 0x0000000112c69289 
QtCore`QFactoryLoader::~QFactoryLoader(this=0x00007fda59e2a3a0) + 9 at 
qfactoryloader.cpp:227
    frame #25: 0x0000000111b93616 QtWidgets`(anonymous 
namespace)::Q_QGS_loader::innerFunction()::Cleanup::~Cleanup() [inlined] 
(anonymous namespace)::Q_QGS_loader::innerFunction()::Cleanup::~Cleanup() + 18 
at qstylefactory.cpp:70
    frame #26: 0x0000000111b93604 QtWidgets`(anonymous 
namespace)::Q_QGS_loader::innerFunction(this=<unavailable>)::Cleanup::~Cleanup() 
+ 4 at qstylefactory.cpp:70
    frame #27: 0x00007fff8342d7b5 libsystem_c.dylib`__cxa_finalize + 177


That one goes away when I simply don't disconnect (but that apparently sometimes 
led to segfaults on Linux when events came in after the receiver was deleted 
(and the style plugin was already dlclose'd)).

R.




More information about the Interest mailing list