Bug 347900

Summary: KWin crashed when I changed my display resolution
Product: [Plasma] kwin Reporter: wodencafe
Component: effects-variousAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: mich.delbianco, wodencafe
Priority: NOR Keywords: drkonqi
Version: 5.2.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 5.3.1
Sentry Crash Report:

Description wodencafe 2015-05-18 12:51:59 UTC
Application: kwin_x11 (5.2.2)

Qt Version: 5.4.1
Operating System: Linux 3.19.0-16-generic x86_64
Distribution: Ubuntu 15.04

-- Information about the crash:
- What I was doing when the application crashed:
I had adjusted the size of my secondary monitor from 1600x1200 to 1920x1080, and after I applied, the screens went black, and then as things were restoring KWin crashed.

The crash can be reproduced sometimes.

-- Backtrace:
Application: KWin (kwin_x11), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fb9a6945800 (LWP 1518))]

Thread 9 (Thread 0x7fb981b21700 (LWP 1535)):
#0  0x00007fb9a640a49d in read () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb998529f85 in ?? () from /usr/lib/nvidia-349/tls/libnvidia-tls.so.349.16
#2  0x00007fb99d5672f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fb99d52396c in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fb99d523e60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fb99d524242 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007fb98c7feae6 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#7  0x00007fb99d54a955 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007fb99da426aa in start_thread (arg=0x7fb981b21700) at pthread_create.c:333
#9  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 8 (Thread 0x7fb981320700 (LWP 1538)):
#0  0x00007fb9a640e8dd in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb99d523ebc in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fb99d523fcc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fb99d524009 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fb99d54a955 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fb99da426aa in start_thread (arg=0x7fb981320700) at pthread_create.c:333
#6  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 7 (Thread 0x7fb980b1f700 (LWP 1552)):
#0  0x00007fb9a6410743 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb9a4c5a101 in qt_safe_select (nfds=24, fdread=fdread@entry=0x7fb978003d48, fdwrite=fdwrite@entry=0x7fb978003fd8, fdexcept=fdexcept@entry=0x7fb978004268, orig_timeout=orig_timeout@entry=0x0) at kernel/qcore_unix.cpp:75
#2  0x00007fb9a4c5bcd2 in select (timeout=0x0, exceptfds=0x7fb978004268, writefds=0x7fb978003fd8, readfds=0x7fb978003d48, nfds=<optimized out>, this=0x7fb978001320) at kernel/qeventdispatcher_unix.cpp:320
#3  QEventDispatcherUNIXPrivate::doSelect (this=this@entry=0x7fb978003bb0, flags=..., flags@entry=..., timeout=timeout@entry=0x0) at kernel/qeventdispatcher_unix.cpp:196
#4  0x00007fb9a4c5c275 in QEventDispatcherUNIX::processEvents (this=0x7fb978001320, flags=...) at kernel/qeventdispatcher_unix.cpp:607
#5  0x00007fb9a4c033e2 in QEventLoop::exec (this=this@entry=0x7fb980b1eda0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:204
#6  0x00007fb9a49c2b44 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:503
#7  0x00007fb99e875f65 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#8  0x00007fb9a49c7b0e in QThreadPrivate::start (arg=0x2882150) at thread/qthread_unix.cpp:337
#9  0x00007fb99da426aa in start_thread (arg=0x7fb980b1f700) at pthread_create.c:333
#10 0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7fb963815700 (LWP 1608)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007fb9a37cc644 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#2  0x00007fb9a37cc689 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#3  0x00007fb99da426aa in start_thread (arg=0x7fb963815700) at pthread_create.c:333
#4  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 5 (Thread 0x7fb9711ea700 (LWP 12009)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007fb9a49c8c6b in wait (time=18446744073709551615, this=0x378c410) at thread/qwaitcondition_unix.cpp:128
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x378c660, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:200
#3  0x00007fb9a3a53fab in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#4  0x00007fb9a3a543a0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#5  0x00007fb9a49c7b0e in QThreadPrivate::start (arg=0x378c5e0) at thread/qthread_unix.cpp:337
#6  0x00007fb99da426aa in start_thread (arg=0x7fb9711ea700) at pthread_create.c:333
#7  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 4 (Thread 0x7fb9733e5700 (LWP 27599)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007fb9a49c8c6b in wait (time=18446744073709551615, this=0x3fdb7e0) at thread/qwaitcondition_unix.cpp:128
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x3fdb550, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:200
#3  0x00007fb9a3a53fab in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#4  0x00007fb9a3a543a0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#5  0x00007fb9a49c7b0e in QThreadPrivate::start (arg=0x3fdb4d0) at thread/qthread_unix.cpp:337
#6  0x00007fb99da426aa in start_thread (arg=0x7fb9733e5700) at pthread_create.c:333
#7  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7fb973fff700 (LWP 7242)):
#0  0x00007fb9a6410743 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fb9a4c5a101 in qt_safe_select (nfds=42, fdread=fdread@entry=0x7fb96c001738, fdwrite=fdwrite@entry=0x7fb96c0019c8, fdexcept=fdexcept@entry=0x7fb96c001c58, orig_timeout=orig_timeout@entry=0x0) at kernel/qcore_unix.cpp:75
#2  0x00007fb9a4c5bcd2 in select (timeout=0x0, exceptfds=0x7fb96c001c58, writefds=0x7fb96c0019c8, readfds=0x7fb96c001738, nfds=<optimized out>, this=0x7fb96c0008c0) at kernel/qeventdispatcher_unix.cpp:320
#3  QEventDispatcherUNIXPrivate::doSelect (this=this@entry=0x7fb96c0015a0, flags=..., flags@entry=..., timeout=timeout@entry=0x0) at kernel/qeventdispatcher_unix.cpp:196
#4  0x00007fb9a4c5c275 in QEventDispatcherUNIX::processEvents (this=0x7fb96c0008c0, flags=...) at kernel/qeventdispatcher_unix.cpp:607
#5  0x00007fb9a4c033e2 in QEventLoop::exec (this=this@entry=0x7fb973ffeda0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:204
#6  0x00007fb9a49c2b44 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:503
#7  0x00007fb99e875f65 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#8  0x00007fb9a49c7b0e in QThreadPrivate::start (arg=0x3b84020) at thread/qthread_unix.cpp:337
#9  0x00007fb99da426aa in start_thread (arg=0x7fb973fff700) at pthread_create.c:333
#10 0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7fb8cf437700 (LWP 7245)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007fb9a49c8c6b in wait (time=18446744073709551615, this=0x43a1d80) at thread/qwaitcondition_unix.cpp:128
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x43b24e0, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:200
#3  0x00007fb9a3a53fab in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#4  0x00007fb9a3a543a0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#5  0x00007fb9a49c7b0e in QThreadPrivate::start (arg=0x43b2460) at thread/qthread_unix.cpp:337
#6  0x00007fb99da426aa in start_thread (arg=0x7fb8cf437700) at pthread_create.c:333
#7  0x00007fb9a6419eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7fb9a6945800 (LWP 1518)):
[KCrash Handler]
#6  KWin::ContrastEffect::uploadRegion (this=this@entry=0x2805b40, map=@0x7fffbbe457a8: 0x7fb9723600a0, region=...) at ../../effects/backgroundcontrast/contrast.cpp:219
#7  0x00007fb9a3d806c5 in KWin::ContrastEffect::uploadGeometry (this=this@entry=0x2805b40, vbo=vbo@entry=0x2d643f0, region=...) at ../../effects/backgroundcontrast/contrast.cpp:235
#8  0x00007fb9a3d8104e in KWin::ContrastEffect::doContrast (this=this@entry=0x2805b40, shape=..., screen=..., opacity=1) at ../../effects/backgroundcontrast/contrast.cpp:361
#9  0x00007fb9a3d81560 in KWin::ContrastEffect::drawWindow (this=this@entry=0x2805b40, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../../effects/backgroundcontrast/contrast.cpp:340
#10 0x00007fb9a5ff90d1 in KWin::EffectsHandlerImpl::drawWindow (this=0x254d8c0, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../effects.cpp:470
#11 0x00007fb9a3cf72db in KWin::BlurEffect::drawWindow (this=this@entry=0x2804e90, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../../effects/blur/blur.cpp:415
#12 0x00007fb9a5ff90d1 in KWin::EffectsHandlerImpl::drawWindow (this=0x254d8c0, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../effects.cpp:470
#13 0x00007fb9a5fc2841 in KWin::Scene::finalPaintWindow (this=<optimized out>, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../scene.cpp:605
#14 0x00007fb9a5ff8f7a in KWin::EffectsHandlerImpl::paintWindow (this=0x254d8c0, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../effects.cpp:436
#15 0x00007fb9a41d3651 in KWin::Effect::paintWindow (this=this@entry=0x2805b40, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../../libkwineffects/kwineffects.cpp:550
#16 0x00007fb9a5ff8f21 in KWin::EffectsHandlerImpl::paintWindow (this=0x254d8c0, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../effects.cpp:433
#17 0x00007fb9a41d3651 in KWin::Effect::paintWindow (this=this@entry=0x2804e90, w=w@entry=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../../libkwineffects/kwineffects.cpp:550
#18 0x00007fb9a5ff8f21 in KWin::EffectsHandlerImpl::paintWindow (this=0x254d8c0, w=0x2dd9140, mask=mask@entry=2, region=..., data=...) at ../effects.cpp:433
#19 0x00007fb9a5fc6ee8 in KWin::Scene::paintWindow (this=this@entry=0x2565450, w=0x2d8a930, mask=2, region=..., quads=...) at ../scene.cpp:477
#20 0x00007fb9a5fc4c0e in KWin::Scene::paintSimpleScreen (this=this@entry=0x2565450, orig_mask=orig_mask@entry=0, region=...) at ../scene.cpp:380
#21 0x00007fb9a5fd5513 in KWin::SceneOpenGL2::paintSimpleScreen (this=this@entry=0x2565450, mask=mask@entry=0, region=...) at ../scene_opengl.cpp:1005
#22 0x00007fb9a5fc2205 in KWin::Scene::finalPaintScreen (this=0x2565450, mask=mask@entry=0, region=..., data=...) at ../scene.cpp:199
#23 0x00007fb9a5ff8cff in KWin::EffectsHandlerImpl::paintScreen (this=0x254d8c0, mask=mask@entry=0, region=..., data=...) at ../effects.cpp:393
#24 0x00007fb9a41d357f in KWin::Effect::paintScreen (this=this@entry=0x2805b40, mask=mask@entry=0, region=..., data=...) at ../../libkwineffects/kwineffects.cpp:535
#25 0x00007fb9a5ff8cad in KWin::EffectsHandlerImpl::paintScreen (this=0x254d8c0, mask=mask@entry=0, region=..., data=...) at ../effects.cpp:390
#26 0x00007fb9a41d357f in KWin::Effect::paintScreen (this=this@entry=0x2804e90, mask=mask@entry=0, region=..., data=...) at ../../libkwineffects/kwineffects.cpp:535
#27 0x00007fb9a5ff8cad in KWin::EffectsHandlerImpl::paintScreen (this=0x254d8c0, mask=0, region=..., data=...) at ../effects.cpp:390
#28 0x00007fb9a5fc1e6a in KWin::Scene::paintScreen (this=this@entry=0x2565450, mask=mask@entry=0x7fffbbe462fc, damage=..., repaint=..., updateRegion=updateRegion@entry=0x7fffbbe46310, validRegion=validRegion@entry=0x7fffbbe46320) at ../scene.cpp:149
#29 0x00007fb9a5fdbda7 in KWin::SceneOpenGL::paint (this=0x2565450, damage=..., toplevels=...) at ../scene_opengl.cpp:651
#30 0x00007fb9a5fbb973 in KWin::Compositor::performCompositing (this=0x278aad0) at ../composite.cpp:658
#31 0x00007fb9a4c376f3 in QObject::event (this=0x278aad0, e=<optimized out>) at kernel/qobject.cpp:1267
#32 0x00007fb9a550fb2c in QApplicationPrivate::notify_helper (this=0x24d90d0, receiver=0x278aad0, e=0x7fffbbe46730) at kernel/qapplication.cpp:3720
#33 0x00007fb9a5515000 in QApplication::notify (this=0x7fffbbe46970, receiver=0x278aad0, e=0x7fffbbe46730) at kernel/qapplication.cpp:3503
#34 0x00007fb9a4c05c2b in QCoreApplication::notifyInternal (this=0x7fffbbe46970, receiver=0x278aad0, event=event@entry=0x7fffbbe46730) at kernel/qcoreapplication.cpp:935
#35 0x00007fb9a4c5dae5 in sendEvent (event=0x7fffbbe46730, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:228
#36 QTimerInfoList::activateTimers (this=0x25a7498) at kernel/qtimerinfo_unix.cpp:635
#37 0x00007fb9a4c5b6a0 in QEventDispatcherUNIX::activateTimers (this=this@entry=0x25a58c0) at kernel/qeventdispatcher_unix.cpp:549
#38 0x00007fb9a4c5c243 in QEventDispatcherUNIX::processEvents (this=0x25a58c0, flags=flags@entry=...) at kernel/qeventdispatcher_unix.cpp:611
#39 0x00007fb98fa7196d in QUnixEventDispatcherQPA::processEvents (this=<optimized out>, flags=...) at eventdispatchers/qunixeventdispatcher.cpp:62
#40 0x00007fb9a4c033e2 in QEventLoop::exec (this=this@entry=0x7fffbbe46890, flags=..., flags@entry=...) at kernel/qeventloop.cpp:204
#41 0x00007fb9a4c0b02c in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1188
#42 0x00007fb9a4f4a31c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1510
#43 0x00007fb9a550b7a5 in QApplication::exec () at kernel/qapplication.cpp:2956
#44 0x00007fb9a66e18c3 in kdemain (argc=1, argv=0x7fffbbe46ac8) at ../main_x11.cpp:294
#45 0x00007fb9a6333a40 in __libc_start_main (main=0x400790 <main(int, char**)>, argc=3, argv=0x7fffbbe46ac8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffbbe46ab8) at libc-start.c:289
#46 0x00000000004007c9 in _start ()

Reported using DrKonqi
Comment 1 Thomas Lübking 2015-05-19 12:22:45 UTC
Untested patch - blur and contrast share too much code, btw.


diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp
index 059a5d8..882055b 100644
--- a/effects/backgroundcontrast/contrast.cpp
+++ b/effects/backgroundcontrast/contrast.cpp
@@ -230,6 +230,8 @@ void ContrastEffect::uploadRegion(QVector2D *&map, const QRegion &region)
 void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &region)
 {
     const int vertexCount = region.rectCount() * 6;
+    if (!vertexCount)
+        return;
 
     QVector2D *map = (QVector2D *) vbo->map(vertexCount * sizeof(QVector2D));
     uploadRegion(map, region);
diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp
index e238bd2..fe0d467 100644
--- a/effects/blur/blur.cpp
+++ b/effects/blur/blur.cpp
@@ -236,6 +236,8 @@ void BlurEffect::uploadRegion(QVector2D *&map, const QRegion &region)
 void BlurEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &horizontal, const QRegion &vertical)
 {
     const int vertexCount = (horizontal.rectCount() + vertical.rectCount()) * 6;
+    if (!vertexCount)
+        return;
 
     QVector2D *map = (QVector2D *) vbo->map(vertexCount * sizeof(QVector2D));
     uploadRegion(map, horizontal);
Comment 2 wodencafe 2015-05-20 03:10:50 UTC
Hi Thomas, I added your patch and built / installed / tested with kwin (5.2.2) and can no longer reproduce the issue.
Comment 3 Thomas Lübking 2015-05-21 08:11:37 UTC
Git commit 12358f839a293d7936e12dbabdd1aca953063b36 by Thomas Lübking.
Committed on 21/05/2015 at 07:42.
Pushed by luebking into branch 'Plasma/5.3'.

no VBO upload for zero vertex count

causes out of bounds segfault
REVIEW: 123865
FIXED-IN: 5.3.1

M  +2    -0    effects/backgroundcontrast/contrast.cpp
M  +2    -0    effects/blur/blur.cpp

http://commits.kde.org/kwin/12358f839a293d7936e12dbabdd1aca953063b36
Comment 4 Thomas Lübking 2015-12-14 08:34:50 UTC
*** Bug 356620 has been marked as a duplicate of this bug. ***