Bug 360593 - Dead-lock with --help on Qt 5.6
Summary: Dead-lock with --help on Qt 5.6
Status: RESOLVED WORKSFORME
Alias: None
Product: Breeze
Classification: Plasma
Component: QStyle (show other bugs)
Version: 5.5.95
Platform: Other Linux
: NOR grave
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-16 07:34 UTC by Martin Flöser
Modified: 2019-10-15 00:28 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
test patch (not to be committed) (1.56 KB, patch)
2016-03-16 10:49 UTC, Hugo Pereira Da Costa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Flöser 2016-03-16 07:34:52 UTC
Running any application with --help will result in the following dead-lock:

pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
185     ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: No such file or directory.
(gdb) bt
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff324c10b in QWaitConditionPrivate::wait (time=18446744073709551615, this=0x6ba300) at thread/qwaitcondition_unix.cpp:136
#2  QWaitCondition::wait (this=this@entry=0x6a3a48, mutex=mutex@entry=0x6a3a40, time=time@entry=18446744073709551615) at thread/qwaitcondition_unix.cpp:208
#3  0x00007ffff324557b in QSemaphore::acquire (this=this@entry=0x7fffffffc660, n=n@entry=1) at thread/qsemaphore.cpp:137
#4  0x00007ffff3438dcf in QMetaObject::activate (sender=sender@entry=0x6a3130, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc6e0) at kernel/qobject.cpp:3698
#5  0x00007ffff3439467 in QMetaObject::activate (sender=sender@entry=0x6a3130, m=m@entry=0x7ffff3652500 <QObject::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc6e0) at kernel/qobject.cpp:3595
#6  0x00007ffff34394ff in QObject::destroyed (this=this@entry=0x6a3130, _t1=_t1@entry=0x6a3130) at .moc/moc_qobject.cpp:213
#7  0x00007ffff343ff95 in QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at kernel/qobject.cpp:913
#8  0x00007fffdc5e24fd in KStyle::~KStyle (this=0x6a3130, __in_chrg=<optimized out>) at /home/martin/src/kf5/frameworks/frameworkintegration/src/kstyle/kstyle.cpp:191
#9  0x00007fffdc82c233 in Breeze::Style::~Style (this=0x6a3130, __in_chrg=<optimized out>) at /home/martin/src/kf5/kde/workspace/breeze/kstyle/breezestyle.cpp:201
#10 0x00007fffdc82c262 in Breeze::Style::~Style (this=0x6a3130, __in_chrg=<optimized out>) at /home/martin/src/kf5/kde/workspace/breeze/kstyle/breezestyle.cpp:207
#11 0x00007fffdc850aeb in Breeze::StylePlugin::<lambda()>::operator()(void) const (__closure=0x7fffffffc820) at /home/martin/src/kf5/kde/workspace/breeze/kstyle/breezestyleplugin.cpp:43
#12 0x00007fffdc850e7a in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, Breeze::StylePlugin::create(const QString&)::<lambda()> >::call(Breeze::StylePlugin::<lambda()>, void **) (f=..., arg=0x7fffffffc9e0)
    at /opt/qt5/include/QtCore/qobjectdefs_impl.h:495
#13 0x00007fffdc850e5b in QtPrivate::Functor<Breeze::StylePlugin::create(const QString&)::<lambda()>, 0>::call<QtPrivate::List<>, void>(Breeze::StylePlugin::<lambda()> &, void *, void **) (f=..., arg=0x7fffffffc9e0)
    at /opt/qt5/include/QtCore/qobjectdefs_impl.h:552
#14 0x00007fffdc850e20 in QtPrivate::QFunctorSlotObject<Breeze::StylePlugin::create(const QString&)::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x6bba20, 
    r=0x6a3130, a=0x7fffffffc9e0, ret=0x0) at /opt/qt5/include/QtCore/qobject_impl.h:192
#15 0x00007ffff3438ebe in QtPrivate::QSlotObjectBase::call (a=0x7fffffffc9e0, r=0x6a3130, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:124
#16 QMetaObject::activate (sender=sender@entry=0x6a84f0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc9e0) at kernel/qobject.cpp:3715
#17 0x00007ffff3439467 in QMetaObject::activate (sender=sender@entry=0x6a84f0, m=m@entry=0x7ffff3652500 <QObject::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc9e0) at kernel/qobject.cpp:3595
#18 0x00007ffff34394ff in QObject::destroyed (this=this@entry=0x6a84f0, _t1=_t1@entry=0x6a84f0) at .moc/moc_qobject.cpp:213
#19 0x00007ffff343ff95 in QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at kernel/qobject.cpp:913
#20 0x00007fffdc850bfe in Breeze::StylePlugin::~StylePlugin (this=0x6a84f0, __in_chrg=<optimized out>) at /home/martin/src/kf5/kde/workspace/breeze/kstyle/breezestyleplugin.cpp:52
#21 0x00007fffdc850c2e in Breeze::StylePlugin::~StylePlugin (this=0x6a84f0, __in_chrg=<optimized out>) at /home/martin/src/kf5/kde/workspace/breeze/kstyle/breezestyleplugin.cpp:54
#22 0x00007ffff3403cd9 in QLibraryPrivate::unload (this=this@entry=0x6ba740, flag=flag@entry=QLibraryPrivate::UnloadSys) at plugin/qlibrary.cpp:551
#23 0x00007ffff33f9ec2 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate (this=0x6ba530, __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:88
#24 0x00007ffff33f9ff9 in QFactoryLoaderPrivate::~QFactoryLoaderPrivate (this=0x6ba530, __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:91
#25 0x00007ffff344037c in QScopedPointerDeleter<QObjectData>::cleanup (pointer=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:54
#26 QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer (this=0x7ffff42ce8c8 <(anonymous namespace)::Q_QGS_loader::innerFunction()::holder+8>, __in_chrg=<optimized out>)
    at ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:101
#27 QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at kernel/qobject.cpp:893
#28 0x00007ffff33f9169 in QFactoryLoader::~QFactoryLoader (this=0x7ffff42ce8c0 <(anonymous namespace)::Q_QGS_loader::innerFunction()::holder>, __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:226
#29 0x00007ffff3e5a0a9 in (anonymous namespace)::Q_QGS_loader::Holder::~Holder (this=<optimized out>, __in_chrg=<optimized out>) at styles/qstylefactory.cpp:70
#30 0x00007ffff259be02 in __run_exit_handlers (status=status@entry=0, listp=0x7ffff2904698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#31 0x00007ffff259be55 in __GI_exit (status=status@entry=0) at exit.c:104
#32 0x00007ffff325bdcf in QCommandLineParser::showHelp (this=this@entry=0x7fffffffce50, exitCode=exitCode@entry=0) at tools/qcommandlineparser.cpp:1010
#33 0x00007ffff325beb5 in QCommandLineParser::process (this=this@entry=0x7fffffffce50, arguments=...) at tools/qcommandlineparser.cpp:590
#34 0x00007ffff325bfcf in QCommandLineParser::process (this=0x7fffffffce50, app=...) at tools/qcommandlineparser.cpp:602
#35 0x0000000000415612 in main ()

I investigated a little bit and a problem seems to be that QFactoryLoader gained a dtor in 5.6 performing a QMutexLock and from destroying the Style another lock is invoked which results in the dead lock.

Reproducible: Always

Steps to Reproduce:
1. gdb --args kwrite --help
2. run
3. wait

Actual Results:  
Application doesn't exit, interrupting in gdb gives backtrace as above

Expected Results:  
application exits cleanly
Comment 1 Heiko Becker 2016-03-16 10:27:33 UTC
I noticed this problem before, but it vanishes for me if qtbase is built with this patch: https://codereview.qt-project.org/#/c/151496/
Comment 2 Hugo Pereira Da Costa 2016-03-16 10:48:28 UTC
@Heiko
Interesting. Indeed breeze does connect to some dbus signals in its constructor.
@Martin,
rather than patching Qt, maybe you can first try the following patch to breeze ? (which just comments the dbus connections) ? 
I cannot test here: do not have recent enough Qt5 (I have 5.5.1)
Comment 3 Hugo Pereira Da Costa 2016-03-16 10:49:21 UTC
Created attachment 97922 [details]
test patch (not to be committed)
Comment 4 Martin Flöser 2016-03-16 11:48:27 UTC
yes, the patch solves the problem
Comment 5 Hugo Pereira Da Costa 2016-03-16 12:06:19 UTC
ok. So definitly related to the issue reported upstream. 
What should we do ? Close as upstream and wait for the patch to go in ? 
Find a workaround ? (no clue how)
Comment out the code ? (in breeze and oxygen) ? 

The debus calls are necessary so that the widget style is updated "on fly" when the configuration is changes via system settings (or breeze-settings, or oxygen-settings)

On one hand Locked application is somewhat a big deal, but on the other hand this only affects corner cases (--help) 

wdyt ?
Comment 6 Martin Flöser 2016-03-16 12:25:07 UTC
(In reply to Hugo Pereira Da Costa from comment #5)
> On one hand Locked application is somewhat a big deal, but on the other hand
> this only affects corner cases (--help) 

nah, it affects more. Every error handling case going directly to ::exit(). I assume it means that one cannot do a kwin_x11 --replace any more and similar things.

What I wanted to try is whether an explicit disconnect in the dtor could help.
Comment 7 Martin Flöser 2016-03-16 12:32:05 UTC
(In reply to Martin Gräßlin from comment #6)
> What I wanted to try is whether an explicit disconnect in the dtor could
> help.

nope, that just results in a crash.
Comment 8 Aleix Pol 2016-04-07 11:04:46 UTC
The Qt patch fixes the issue for me.
Comment 9 David Edmundson 2019-10-15 00:28:49 UTC
This seems to be not true anymore.