Bug 383054

Summary: Crash in autocompletion of kdevelop
Product: [Frameworks and Libraries] kwayland Reporter: Martin Flöser <mgraesslin>
Component: serverAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version First Reported In: 5.36.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: https://phabricator.kde.org/D7078
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Martin Flöser 2017-08-02 16:48:26 UTC
Steps to reproduce:
1. use kdevelop
2. use lots of auto-completion
3. wait

Thread 1 "kwin_wayland" received signal SIGSEGV, Segmentation fault.
0x00007f258a2c6560 in KWayland::Server::DataSourceInterface::d_func() const () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
(gdb) t a a bt

Thread 9 (Thread 0x7f254affd700 (LWP 1305)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f2588057784 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#2  0x00007f25880577c9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#3  0x00007f258a0606ba in start_thread (arg=0x7f254affd700) at pthread_create.c:333
#4  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 8 (Thread 0x7f254bfff700 (LWP 1303)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f258908d8eb in QWaitConditionPrivate::wait (time=18446744073709551615, this=0x4114f40) at thread/qwaitcondition_unix.cpp:143
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x4114168, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:215
#3  0x00007f2568140f22 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/qml/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so
#4  0x00007f258908c989 in QThreadPrivate::start (arg=0x4114158) at thread/qthread_unix.cpp:368
#5  0x00007f258a0606ba in start_thread (arg=0x7f254bfff700) at pthread_create.c:333
#6  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 7 (Thread 0x7f2554b5c700 (LWP 1302)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007f258908d8eb in QWaitConditionPrivate::wait (time=18446744073709551615, this=0x41acc80) at thread/qwaitcondition_unix.cpp:143
#2  QWaitCondition::wait (this=this@entry=0x4166998, mutex=mutex@entry=0x4166990, time=time@entry=18446744073709551615) at thread/qwaitcondition_unix.cpp:215
#3  0x00007f258908676b in QSemaphore::acquire (this=0x41aff18, n=1) at thread/qsemaphore.cpp:143
#4  0x00007f2571dc116b in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so
#5  0x00007f258908c989 in QThreadPrivate::start (arg=0x41aff00) at thread/qthread_unix.cpp:368
#6  0x00007f258a0606ba in start_thread (arg=0x7f2554b5c700) at pthread_create.c:333
#7  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7f2555f5d700 (LWP 1301)):
#0  0x00007f258876b70d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f258100e38c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f258100e49c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f25892b592f in QEventDispatcherGlib::processEvents (this=0x7f254c0008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#4  0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7f2555f5cc60, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#5  0x00007f2589087cd4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:515
#6  0x00007f2584315fa5 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7  0x00007f258908c989 in QThreadPrivate::start (arg=0x3f94540) at thread/qthread_unix.cpp:368
#8  0x00007f258a0606ba in start_thread (arg=0x7f2555f5d700) at pthread_create.c:333
#9  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 5 (Thread 0x7f255f0ce700 (LWP 1300)):
#0  0x00007f258876b70d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f258100e38c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#2  0x00007f258100e49c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f25892b594b in QEventDispatcherGlib::processEvents (this=0x7f25500008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#4  0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7f255f0cdc60, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#5  0x00007f2589087cd4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:515
#6  0x00007f2584315fa5 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7  0x00007f258908c989 in QThreadPrivate::start (arg=0x400aaf0) at thread/qthread_unix.cpp:368
#8  0x00007f258a0606ba in start_thread (arg=0x7f255f0ce700) at pthread_create.c:333
#9  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 4 (Thread 0x7f256b5ef700 (LWP 1281)):
#0  0x00007f258876b70d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f258100e38c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f258100e49c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f25892b592f in QEventDispatcherGlib::processEvents (this=0x7f25600008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#4  0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7f256b5eec80, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#5  0x00007f2589087cd4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:515
#6  0x00007f258908c989 in QThreadPrivate::start (arg=0x21df730) at thread/qthread_unix.cpp:368
#7  0x00007f258a0606ba in start_thread (arg=0x7f256b5ef700) at pthread_create.c:333
#8  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7f2570c71700 (LWP 1280)):
#0  0x00007f258876b70d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f258100e38c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f258100e49c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f25892b592f in QEventDispatcherGlib::processEvents (this=0x7f25640008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#4  0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7f2570c70c80, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#5  0x00007f2589087cd4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:515
#6  0x00007f258908c989 in QThreadPrivate::start (arg=0x20e8310) at thread/qthread_unix.cpp:368
#7  0x00007f258a0606ba in start_thread (arg=0x7f2570c71700) at pthread_create.c:333
#8  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7f257169d700 (LWP 1279)):
#0  0x00007f258876b70d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00007f258100e38c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f258100e49c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f25892b594b in QEventDispatcherGlib::processEvents (this=0x7f256c0008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#4  0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7f257169cc50, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#5  0x00007f2589087cd4 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:515
#6  0x00007f258b022b75 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007f258908c989 in QThreadPrivate::start (arg=0x7f258b098da0) at thread/qthread_unix.cpp:368
#8  0x00007f258a0606ba in start_thread (arg=0x7f257169d700) at pthread_create.c:333
#9  0x00007f25887773dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
---Type <return> to continue, or q <return> to quit---

Thread 1 (Thread 0x7f2573678940 (LWP 1278)):
#0  0x00007f258a2c6560 in KWayland::Server::DataSourceInterface::d_func() const () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
#1  0x00007f258a2c65c1 in KWayland::Server::DataSourceInterface::mimeTypes() const () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
#2  0x00007f258a2c60b1 in KWayland::Server::DataOfferInterface::sendAllOffers() () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
#3  0x00007f258a2c4c1d in KWayland::Server::DataDeviceInterface::Private::createDataOffer(KWayland::Server::DataSourceInterface*) () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
#4  0x00007f258a2c4dd4 in KWayland::Server::DataDeviceInterface::sendSelection(KWayland::Server::DataDeviceInterface*) () from /usr/lib/x86_64-linux-gnu/libKF5WaylandServer.so.5
#5  0x00007f258aaa84e8 in KWin::KeyboardInputRedirection::update (this=<optimized out>) at /workspace/build/keyboard_input.cpp:187
#6  0x00007f258aaa8624 in KWin::KeyboardInputRedirection::<lambda()>::operator() (__closure=0x3f9bb30) at /workspace/build/keyboard_input.cpp:137
#7  QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KWin::KeyboardInputRedirection::init()::<lambda()> >::call (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:130
#8  QtPrivate::Functor<KWin::KeyboardInputRedirection::init()::<lambda()>, 0>::call<QtPrivate::List<>, void> (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:240
#9  QtPrivate::QFunctorSlotObject<KWin::KeyboardInputRedirection::init()::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=<optimized out>, this_=0x3f9bb20, 
    r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:168
#10 0x00007f258928cf46 in QtPrivate::QSlotObjectBase::call (a=0x7fff3bc18580, r=0x20ef650, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
#11 QMetaObject::activate (sender=sender@entry=0x3f8c0e0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff3bc18580) at kernel/qobject.cpp:3749
#12 0x00007f258928d527 in QMetaObject::activate (sender=sender@entry=0x3f8c0e0, m=m@entry=0x7f258aec8c20 <KWin::Workspace::staticMetaObject>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fff3bc18580)
    at kernel/qobject.cpp:3628
#13 0x00007f258ac0c4e2 in KWin::Workspace::clientActivated (this=this@entry=0x3f8c0e0, _t1=0x439ed40) at /workspace/build/obj-x86_64-linux-gnu/moc_workspace.cpp:716
#14 0x00007f258aaf566d in KWin::Workspace::setActiveClient (this=0x3f8c0e0, c=0x439ed40) at /workspace/build/activation.cpp:275
#15 0x00007f258aa72f46 in KWin::AbstractClient::setActive (this=this@entry=0x439ed40, act=act@entry=true) at /workspace/build/abstract_client.cpp:206
#16 0x00007f258aad7d75 in KWin::Client::focusInEvent (this=0x439ed40, e=<optimized out>) at /workspace/build/events.cpp:1296
#17 0x00007f258aad9193 in KWin::Client::windowEvent (this=0x439ed40, e=e@entry=0x49de6c0) at /workspace/build/events.cpp:725
#18 0x00007f258aada8aa in KWin::Workspace::workspaceEvent (this=<optimized out>, e=0x49de6c0) at /workspace/build/events.cpp:349
#19 0x00007f258925d3af in QAbstractEventDispatcher::filterNativeEvent (this=<optimized out>, eventType=..., message=message@entry=0x49de6c0, result=result@entry=0x7fff3bc188c0) at kernel/qabstracteventdispatcher.cpp:467
#20 0x0000000000409056 in KWin::ApplicationWayland::<lambda()>::operator() (__closure=<optimized out>) at /workspace/build/main_wayland.cpp:176
#21 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KWin::ApplicationWayland::continueStartupWithX()::<lambda()> >::call (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:130
#22 QtPrivate::Functor<KWin::ApplicationWayland::continueStartupWithX()::<lambda()>, 0>::call<QtPrivate::List<>, void> (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:240
#23 QtPrivate::QFunctorSlotObject<KWin::ApplicationWayland::continueStartupWithX()::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=<optimized out>, this_=0x2356b10, 
    r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:168
#24 0x00007f258928cf46 in QtPrivate::QSlotObjectBase::call (a=0x7fff3bc189c0, r=0x7fff3bc18eb0, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
#25 QMetaObject::activate (sender=sender@entry=0x208d240, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x0) at kernel/qobject.cpp:3749
#26 0x00007f258928d527 in QMetaObject::activate (sender=sender@entry=0x208d240, m=m@entry=0x7f2589517380 <QAbstractEventDispatcher::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x0)
    at kernel/qobject.cpp:3628
#27 0x00007f258925cb13 in QAbstractEventDispatcher::awake (this=this@entry=0x208d240) at .moc/moc_qabstracteventdispatcher.cpp:145
#28 0x00007f25892b27da in QEventDispatcherUNIX::processEvents (this=0x208d240, flags=...) at kernel/qeventdispatcher_unix.cpp:465
#29 0x00007f2573148ccd in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/KWinQpaPlugin.so
#30 0x00007f258925e7ca in QEventLoop::exec (this=this@entry=0x7fff3bc18b80, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#31 0x00007f2589267704 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1291
#32 0x00007f25830d12ec in QGuiApplication::exec () at kernel/qguiapplication.cpp:1679
#33 0x00007f2589679355 in QApplication::exec () at kernel/qapplication.cpp:2905
#34 0x0000000000408928 in main (argc=4, argv=<optimized out>) at /workspace/build/main_wayland.cpp:763
Comment 1 Martin Flöser 2017-08-02 17:20:57 UTC
Relevant part in KWayland:
#0  0x00007ffff77d53ee in QScopedPointer<KWayland::Server::Resource::Private, QScopedPointerDeleter<KWayland::Server::Resource::Private> >::data (this=0x10) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qscopedpointer.h:141
#1  0x00007ffff77d6b3a in KWayland::Server::DataSourceInterface::d_func (this=0x0) at /home/martin/src/kf5/frameworks/kwayland/src/server/datasource_interface.cpp:129
#2  0x00007ffff77d6ae2 in KWayland::Server::DataSourceInterface::mimeTypes (this=0x0) at /home/martin/src/kf5/frameworks/kwayland/src/server/datasource_interface.cpp:118
#3  0x00007ffff77d5dc9 in KWayland::Server::DataOfferInterface::sendAllOffers (this=0x5555557cff20) at /home/martin/src/kf5/frameworks/kwayland/src/server/dataoffer_interface.cpp:119
#4  0x00007ffff77d3fc6 in KWayland::Server::DataDeviceInterface::Private::createDataOffer (this=0x5555557cda00, source=0x0) at /home/martin/src/kf5/frameworks/kwayland/src/server/datadevice_interface.cpp:160
#5  0x00007ffff77d4194 in KWayland::Server::DataDeviceInterface::sendSelection (this=0x5555557cd780, other=0x5555557cd780) at /home/martin/src/kf5/frameworks/kwayland/src/server/datadevice_interface.cpp:204
Comment 2 Martin Flöser 2017-08-02 17:26:21 UTC
Patch at https://phabricator.kde.org/D7078
Comment 3 David Edmundson 2017-08-17 15:25:22 UTC
Git commit 1b2794985361b12923b31ce83fb202a70cddf624 by David Edmundson.
Committed on 15/08/2017 at 23:17.
Pushed by davidedmundson into branch 'master'.

Avoid sending data offers from an invalid source.

Summary:
A DataDevice will have a source when offers are available, but it can
also be legitimately cleared.

When calling DataDeviceInterface::sendSelection(DataDeviceInterface
*other) if the other data device has no source, we should be setting
that we also have no source.

In addition this also guards against Seat tracking a DataDeviceInterface
with no source when trying to sync x clipboards.

Reviewers: #plasma

Subscribers: graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

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

M  +3    -0    autotests/client/test_wayland_seat.cpp
M  +6    -1    src/server/datadevice_interface.cpp

https://commits.kde.org/kwayland/1b2794985361b12923b31ce83fb202a70cddf624