Bug 374554

Summary: Crash when enabling DPMS
Product: [Plasma] kwin Reporter: Martin Flöser <mgraesslin>
Component: libinputAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: subdiff
Priority: VHI Flags: mgraesslin: Wayland+
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Martin Flöser 2017-01-04 18:08:01 UTC
Steps to reproduce:
1. run kwayland/tests/dpmsTest
2. Select Off

Expected Result:
dpms is enabled

Actual Result:
KWin crashes

Thread 1 "kwin_wayland" received signal SIGSEGV, Segmentation fault.
QtPrivate::RefCount::ref (this=0x0) at ../../include/QtCore/../../src/corelib/tools/qrefcount.h:55
55      ../../include/QtCore/../../src/corelib/tools/qrefcount.h: No such file or directory.
(gdb) t a a bt

Thread 11 (Thread 0x7f030ce83700 (LWP 1965)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f033c6d05c4 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#2  0x00007f033c6d0609 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#3  0x00007f033e6686ba in start_thread (arg=0x7f030ce83700) at pthread_create.c:333
#4  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 9 (Thread 0x7f030de85700 (LWP 1963)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f033d6faa4b in QWaitConditionPrivate::wait (time=18446744073709551615, this=0x2b8e7a0) at thread/qwaitcondition_unix.cpp:143
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x2b8e1c8, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:215
#3  0x00007f03141fd482 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/qml/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so
#4  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x2b8e1b8) at thread/qthread_unix.cpp:344
#5  0x00007f033e6686ba in start_thread (arg=0x7f030de85700) at pthread_create.c:333
#6  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 8 (Thread 0x7f030e686700 (LWP 1962)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f033d6faa4b in QWaitConditionPrivate::wait (time=18446744073709551615, this=0x2b8da90) at thread/qwaitcondition_unix.cpp:143
#2  QWaitCondition::wait (this=this@entry=0x2c09fa8, mutex=mutex@entry=0x2c09fa0, time=time@entry=18446744073709551615) at thread/qwaitcondition_unix.cpp:215
#3  0x00007f033d6f3bfb in QSemaphore::acquire (this=0x2c098e8, n=1) at thread/qsemaphore.cpp:143
#4  0x00007f0327760578 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so
#5  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x2c098d0) at thread/qthread_unix.cpp:344
#6  0x00007f033e6686ba in start_thread (arg=0x7f030e686700) at pthread_create.c:333
#7  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 7 (Thread 0x7f030f687700 (LWP 1961)):
#0  0x00007f033cdd8b5d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f03356c839c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f03356c84ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f033d92521f in QEventDispatcherGlib::processEvents (this=0x7f03040008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#4  0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7f030f686c60, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#5  0x00007f033d6f4fb4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:507
#6  0x00007f03389f0675 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x2b344a0) at thread/qthread_unix.cpp:344
#8  0x00007f033e6686ba in start_thread (arg=0x7f030f687700) at pthread_create.c:333
#9  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7f0314eb6700 (LWP 1960)):
#0  0x00007f033cdd8b5d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f03356c839c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#2  0x00007f03356c84ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f033d92523b in QEventDispatcherGlib::processEvents (this=0x7f03080008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#4  0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7f0314eb5c60, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#5  0x00007f033d6f4fb4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:507
#6  0x00007f03389f0675 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x2a88590) at thread/qthread_unix.cpp:344
#8  0x00007f033e6686ba in start_thread (arg=0x7f0314eb6700) at pthread_create.c:333
#9  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 4 (Thread 0x7f0325209700 (LWP 1942)):
#0  0x00007f033cdd8b5d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f03356c839c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f03356c84ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f033d92523b in QEventDispatcherGlib::processEvents (this=0x7f031c0008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#4  0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7f0325208c80, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#5  0x00007f033d6f4fb4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:507
#6  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x1f8b970) at thread/qthread_unix.cpp:344
#7  0x00007f033e6686ba in start_thread (arg=0x7f0325209700) at pthread_create.c:333
#8  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7f032661e700 (LWP 1941)):
#0  0x00007f033cdd8b5d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f03356c839c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f03356c84ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f033d92521f in QEventDispatcherGlib::processEvents (this=0x7f03180008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#4  0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7f032661dc80, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#5  0x00007f033d6f4fb4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:507
#6  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x1e32770) at thread/qthread_unix.cpp:344
#7  0x00007f033e6686ba in start_thread (arg=0x7f032661e700) at pthread_create.c:333
#8  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7f0327047700 (LWP 1940)):
#0  0x00007f033cdd8b5d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f03356c839c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f03356c84ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f033d92523b in QEventDispatcherGlib::processEvents (this=0x7f03200008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#4  0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7f0327046c50, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#5  0x00007f033d6f4fb4 in QThread::exec (this=this@entry=0x7f033f676d60 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread.cpp:507
#6  0x00007f033f6027a5 in QDBusConnectionManager::run (this=0x7f033f676d60 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at qdbusconnection.cpp:196
#7  0x00007f033d6f9b98 in QThreadPrivate::start (arg=0x7f033f676d60 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread_unix.cpp:344
#8  0x00007f033e6686ba in start_thread (arg=0x7f0327047700) at pthread_create.c:333
#9  0x00007f033cde482d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
---Type <return> to continue, or q <return> to quit---

Thread 1 (Thread 0x7f033f4da940 (LWP 1939)):
#0  QtPrivate::RefCount::ref (this=0x0) at ../../include/QtCore/../../src/corelib/tools/qrefcount.h:55
#1  0x00007f033d918c8d in QByteArray::QByteArray (a=..., this=0x7fff54e912f0) at ../../include/QtCore/../../src/corelib/tools/qbytearray.h:505
#2  QBitArray::QBitArray (other=..., this=0x7fff54e912f0) at ../../include/QtCore/../../src/corelib/tools/qbitarray.h:59
#3  v_construct_helper<QBitArray> (t=..., x=0x7fff54e912f0) at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qvariant_p.h:123
#4  v_construct<QBitArray> (t=..., x=0x7fff54e912f0) at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qvariant_p.h:152
#5  v_construct<QBitArray> (copy=0x7fff54e9160c, x=0x7fff54e912f0) at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qvariant_p.h:160
#6  QVariantConstructor<(anonymous namespace)::CoreTypesFilter>::FilteredConstructor<QByteArray, true>::FilteredConstructor (this=<optimized out>, tc=<synthetic pointer>)
    at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qvariant_p.h:321
#7  QVariantConstructor<(anonymous namespace)::CoreTypesFilter>::delegate<QByteArray> (this=<synthetic pointer>) at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qvariant_p.h:342
#8  QMetaTypeSwitcher::switcher<void, QVariantConstructor<(anonymous namespace)::CoreTypesFilter> > (data=0x0, type=<optimized out>, logic=<synthetic pointer>)
    at ../../include/QtCore/5.7.0/QtCore/private/../../../../../src/corelib/kernel/qmetatypeswitcher_p.h:74
#9  (anonymous namespace)::construct (x=0x7fff54e912f0, copy=0x7fff54e9160c) at kernel/qvariant.cpp:113
#10 0x00007f033d90e09f in QVariant::QVariant (this=0x7fff54e912f0, typeId=<optimized out>, copy=<optimized out>) at kernel/qvariant.cpp:1680
#11 0x00007f033f632ed2 in QDBusAdaptorConnector::relay (this=this@entry=0x2030090, senderObj=senderObj@entry=0x2194b20, lastSignalIdx=22, argv=argv@entry=0x7fff54e91610) at qdbusabstractadaptor.cpp:330
#12 0x00007f033f6330cf in QDBusAdaptorConnector::relaySlot (this=0x2030090, argv=0x7fff54e91610) at qdbusabstractadaptor.cpp:283
#13 0x00007f033f633f68 in QDBusAdaptorConnector::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at qdbusabstractadaptor.cpp:405
#14 0x00007f033f634093 in QDBusAdaptorConnector::qt_metacall (this=0x2030090, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0x7fff54e91610) at qdbusabstractadaptor.cpp:437
#15 0x00007f033d8fcc94 in QMetaObject::activate (sender=sender@entry=0x2194b20, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=13, argv=argv@entry=0x7fff54e91610) at kernel/qobject.cpp:3755
#16 0x00007f033d8fd4b7 in QMetaObject::activate (sender=sender@entry=0x2194b20, m=m@entry=0x7f033f4a1c60 <KWin::LibInput::Connection::staticMetaObject>, local_signal_index=local_signal_index@entry=13, argv=argv@entry=0x7fff54e91610)
    at kernel/qobject.cpp:3602
#17 0x00007f033f1ec622 in KWin::LibInput::Connection::hasTouchChanged (this=this@entry=0x2194b20, _t1=_t1@entry=false) at /workspace/build/obj-x86_64-linux-gnu/moc_connection.cpp:624
#18 0x00007f033f1dcb7e in KWin::LibInput::Connection::processEvents (this=0x2194b20) at /workspace/build/libinput/connection.cpp:312
#19 0x00007f033d8fda19 in QObject::event (this=0x1e39030, e=<optimized out>) at kernel/qobject.cpp:1263
#20 0x00007f033dc7d89c in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x1e39030, e=0x7f031c002c90) at kernel/qapplication.cpp:3799
#21 0x00007f033dc85296 in QApplication::notify (this=0x7fff54e91e80, receiver=0x1e39030, e=0x7f031c002c90) at kernel/qapplication.cpp:3556
#22 0x00007f033d8d1cf8 in QCoreApplication::notifyInternal2 (receiver=0x1e39030, event=event@entry=0x7f031c002c90) at kernel/qcoreapplication.cpp:988
#23 0x00007f033d8d43bb in QCoreApplication::sendEvent (event=0x7f031c002c90, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#24 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x1dc9400) at kernel/qcoreapplication.cpp:1649
#25 0x00007f033d921d1a in QEventDispatcherUNIX::processEvents (this=0x1de1570, flags=...) at kernel/qeventdispatcher_unix.cpp:461
#26 0x00007f0328a8239d in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/KWinQpaPlugin.so
#27 0x00007f033d8cfcea in QEventLoop::exec (this=this@entry=0x7fff54e91b70, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
#28 0x00007f033d8d82fc in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1261
#29 0x00007f03377a5d9c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1639
#30 0x00007f033dc7d7f5 in QApplication::exec () at kernel/qapplication.cpp:2975
#31 0x0000000000408754 in main (argc=4, argv=<optimized out>) at /workspace/build/main_wayland.cpp:747
Comment 1 Roman Gilg 2017-01-08 14:05:19 UTC
Since you thought a few days ago the org.kde.KWin.InputDeviceManager interface is the problem because of the backtrace, something else:

When issuing kwin_wayland --xwayland from terminal, it gives a segfault. Removing the registerObject of the interface in connection.cpp solves this. So there is indeed a problem with the current implementation, which seems to be related to the multiple threads in the Connection class. Atleast there are correlated warning messages spamed to the log.
Comment 2 Martin Flöser 2017-01-08 17:25:34 UTC
What if we move the register into the doInit method which is called in the connection thread? Currently the register is done from ctor which is main thread.
Comment 3 Roman Gilg 2017-01-08 20:20:13 UTC
Didn't work for me. But try this out instead: https://phabricator.kde.org/D4027
Comment 4 Roman Gilg 2017-01-09 08:12:56 UTC
Git commit b868df2715d2b81a9d7f556ef57de5fb8aa99baa by Roman Gilg.
Committed on 09/01/2017 at 08:07.
Pushed by romangilg into branch 'master'.

[libinput] Fix threaded Connection DBus object registering

On registering object use the object in the right thread.
Otherwise there are multiple errors.

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

M  +1    -1    libinput/connection.cpp

https://commits.kde.org/kwin/b868df2715d2b81a9d7f556ef57de5fb8aa99baa
Comment 5 Martin Flöser 2017-01-10 19:40:14 UTC
Just tested with latest neon and I can turn the screen off again! Thanks a lot!