Bug 634305

Summary: intel [GM45] Kwin 4.5 crashes with VSync enabled
Product: [openSUSE] openSUSE 11.3 Reporter: Michal Vyskocil <mvyskocil>
Component: KDE4 WorkspaceAssignee: E-mail List <kde-maintainers>
Status: VERIFIED NORESPONSE QA Contact: E-mail List <qa-bugs>
Severity: Critical    
Priority: P3 - Medium CC: ctrippe, forgotten_kHYb7eJGnH
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Michal Vyskocil 2010-08-25 07:28:51 UTC
When querying which desktop effect might cause the X server freeze tracked in bnc#597078 when using KMS and intel driver, I found the workaround - enable VSync. With this option no freeze appears, but the kwin crashes every time I push Apply button (I assume this crash maybe prevents the X freeze ;-)) in systemsettings.

Installed related packages
kwin-4.5.0-493.4.x86_64 (KDE:KDE4:Factory:Desktop)
xorg-x11-server-7.5_1.8.0-10.3.1.x86_64 (11.3-update-test)
kernel-desktop-2.6.35.1-3.1.x86_64 (Kernel:HEAD)

This is a trace from kwin - not sure if it's kwin or Xorg related

Application: KWin (kwin), signal: Segmentation fault
[KCrash Handler]
#6  dri2DrawableGetMSC (psc=0x7f3214001370, pdraw=0x0, ust=0x7fff4a77e318, msc=0x7fff4a77e310, sbc=0x7fff4a77e308) at dri2_glx.c:226
#7  0x00007f322e34a185 in __glXGetVideoSyncSGI (count=0x7fff4a77e35c) at glxcmds.c:2317
#8  0x00007f323089dc21 in KWin::SceneOpenGL::waitSync (this=<value optimized out>) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:781
#9  0x00007f32308b1570 in KWin::SceneOpenGL::flushBuffer (this=0x740b60, mask=<value optimized out>, damage=...) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:830
#10 0x00007f32308fb530 in KWin::SceneOpenGL::paint (this=0x740b60, damage=..., toplevels=<value optimized out>) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:761
#11 0x00007f32308dc3f9 in KWin::Workspace::performCompositing (this=0x7f3214008a50) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/composite.cpp:454
#12 0x00007f3230909c15 in KWin::Workspace::qt_metacall (this=0x7f3214008a50, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fff4a77e7a0)
    at /usr/src/debug/kdebase-workspace-4.5.0/build/kwin/workspace.moc:583
#13 0x00007f322cef9a1f in QMetaObject::activate (sender=0x7f3214008f18, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3295
#14 0x00007f322cef722e in QObject::event (this=0x7f3214008f18, e=0x7fff4a77ef40) at kernel/qobject.cpp:1212
#15 0x00007f322c0ba4d4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#16 0x00007f322c0c2aca in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#17 0x00007f323004e0b6 in KApplication::notify(QObject*, QEvent*) () from /usr/lib64/libkdeui.so.5
#18 0x00007f322cee5e4c in QCoreApplication::notifyInternal (this=0x7fff4a77f450, receiver=0x7f3214008f18, event=0x7fff4a77ef40) at kernel/qcoreapplication.cpp:726
#19 0x00007f322cf110c9 in sendEvent (this=0x6341a0) at kernel/qcoreapplication.h:215
#20 QTimerInfoList::activateTimers (this=0x6341a0) at kernel/qeventdispatcher_unix.cpp:618
#21 0x00007f322cf118c0 in QEventDispatcherUNIX::processEvents (this=0x612010, flags=...) at kernel/qeventdispatcher_unix.cpp:939
#22 0x00007f322c15bcbc in ?? () from /usr/lib64/libQtGui.so.4
#23 0x00007f322cee5292 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#24 0x00007f322cee5495 in QEventLoop::exec (this=0x7fff4a77f390, flags=...) at kernel/qeventloop.cpp:201
#25 0x00007f322cee988b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1003
#26 0x00007f3230908314 in kdemain (argc=<value optimized out>, argv=0x7fff4a77f450) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/main.cpp:531
#27 0x00007f32304ffb7d in __libc_start_main () from /lib64/libc.so.6
#28 0x0000000000400699 in _start () at ../sysdeps/x86_64/elf/start.S:113
Comment 1 Michal Vyskocil 2010-08-25 07:35:36 UTC
(In reply to comment #0)
> 
> Installed related packages
> kwin-4.5.0-493.4.x86_64 (KDE:KDE4:Factory:Desktop)
> xorg-x11-server-7.5_1.8.0-10.3.1.x86_64 (11.3-update-test)
> kernel-desktop-2.6.35.1-3.1.x86_64 (Kernel:HEAD)
> 

I forgot - the reason why I have newest x server and kernel is I wanted to check if more recent versions do not contain a fix for this bug. If you think the reproducer on clean 11.3 (+ KDE 4.5) is needed, please let me know.
Comment 2 Lubos Lunak 2010-08-25 08:57:18 UTC
The crash is in GLX -> X.
Comment 3 Stefan Dirsch 2010-08-25 12:35:24 UTC
Well, the crash is in Mesa (./src/glx/dri2_glx.c). How did you enable VRefresh?
Comment 4 Stefan Dirsch 2010-08-25 12:37:55 UTC
Sorry, I mean Vsync.
Comment 5 Stefan Dirsch 2010-08-25 12:52:00 UTC
Whatever. I mean the value for vblank_mode ...
Comment 6 Stefan Dirsch 2010-08-25 13:00:31 UTC
Braindead fix (untested).

--- src/glx/dri2_glx.c.orig     2010-08-25 14:56:59.000000000 +0200
+++ src/glx/dri2_glx.c  2010-08-25 15:00:01.000000000 +0200
@@ -223,6 +223,8 @@ static int
 dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
                   int64_t *ust, int64_t *msc, int64_t *sbc)
 {
+   if (!pdraw)
+       return False;
    return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc);
 }
Comment 7 Michal Vyskocil 2010-08-25 13:50:22 UTC
There's a checkbox on Advanced Tab of kwin, which is called Use VSync - don't know what's doing, I just randomly tested all possible kwin settings.
Comment 8 Michal Vyskocil 2010-08-26 10:07:45 UTC
I found the similar problem (also due kwin's crash) and a proposed patch [1], which was not accepted by upstream [2], because it just hides the main problem, which is few lines above in GetGLXDRIDrawable, which should not return NULL according upstream.

Lubos, can you check the question in [2], please?

http://lists.freedesktop.org/archives/mesa-dev/2010-July/001604.html
http://lists.freedesktop.org/archives/mesa-dev/2010-July/001638.html
Comment 9 Stefan Dirsch 2010-08-26 10:51:43 UTC
> Installed related packages
> kwin-4.5.0-493.4.x86_64 (KDE:KDE4:Factory:Desktop)

project doesn't exist. I've updated KDE4 to 4.5 from KDE:Distro:Factory/openSUSE_11.3 instead.

--> kwin-4.5.0-493.4.i586

> xorg-x11-server-7.5_1.8.0-10.3.1.x86_64 (11.3-update-test)

xorg-x11-server-7.5_1.8.0-10.3.1.i586

> kernel-desktop-2.6.35.1-3.1.x86_64 (Kernel:HEAD)

Meanwhile no longer available. 2.6.36-rc2 give me a blank screen (KMS broken?),
so I've installed the update kernel for 11.3 instead.

kernel-desktop-2.6.34.4-0.1.1.i586

Anyway, I can't reproduce that issue at all on my GM45 machine.
Comment 10 Stefan Dirsch 2010-08-26 10:53:21 UTC
(In reply to comment #8)
> http://lists.freedesktop.org/archives/mesa-dev/2010-July/001604.html

The patch is for a later Mesa version. For now I'm going to apply my patch and provide you a package for testing, since I can't reproduce the issue.
Comment 11 Michal Vyskocil 2010-08-26 12:33:14 UTC
(In reply to comment #9)
> Meanwhile no longer available. 2.6.36-rc2 give me a blank screen (KMS broken?),
> so I've installed the update kernel for 11.3 instead.

I have this problem in .36 from Kernel:HEAD too. It's independent on kernel/X version.

> 
> kernel-desktop-2.6.34.4-0.1.1.i586
> 
> Anyway, I can't reproduce that issue at all on my GM45 machine.

That's sad

(In reply to comment #10)
> (In reply to comment #8)
> > http://lists.freedesktop.org/archives/mesa-dev/2010-July/001604.html
> 
> The patch is for a later Mesa version. For now I'm going to apply my patch and
> provide you a package for testing, since I can't reproduce the issue.

OK, I'll retest it asap. Thanks a lot.
Comment 12 Stefan Dirsch 2010-08-26 12:47:22 UTC
Mesa packages including the patch will be available shortly via

  http://beta.suse.com/private/sndirsch/bug634305/

# rpm --force Mesa-7.8.2-1.x86_64.rpm \
              Mesa-debuginfo-7.8.2-1.x86_64.rpm \
              Mesa-debugsource-7.8.2-1.x86_64.rpm \
              Mesa-devel-7.8.2-1.x86_64.rpm

# rpm --changelog -q Mesa-7.8.2-1.x86_64.rpm
* Do Aug 26 2010 sndirsch@suse.de
- sig11-bug634305.diff
  * possibly fixes segfault in Mesa on intel-GM45 machines when
    VSync has been enabled for desktop effects (bnc #634305)
Comment 13 Michal Vyskocil 2010-08-26 13:26:11 UTC
Did not help, there are tons of places which segfaults on empty pdraw.

Application: KWin (kwin), signal: Segmentation fault
[KCrash Handler]
#6  dri2WaitForMSC (pdraw=0x0, target_msc=0, divisor=2, remainder=1, ust=0x7fff6f7d7798, msc=0x7fff6f7d7790, sbc=0x7fff6f7d7788) at dri2_glx.c:240
#7  0x00007f94dafd6085 in __glXWaitVideoSyncSGI (divisor=2, remainder=1, count=0x7fff6f7d77ec) at glxcmds.c:2364
#8  0x00007f94dd529c3c in KWin::SceneOpenGL::waitSync (this=<value optimized out>) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:782
#9  0x00007f94dd53d570 in KWin::SceneOpenGL::flushBuffer (this=0x751d50, mask=<value optimized out>, damage=...) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:830
#10 0x00007f94dd587530 in KWin::SceneOpenGL::paint (this=0x751d50, damage=..., toplevels=<value optimized out>) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/scene_opengl.cpp:761
#11 0x00007f94dd5683f9 in KWin::Workspace::performCompositing (this=0x741ba0) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/composite.cpp:454
#12 0x00007f94dd595c15 in KWin::Workspace::qt_metacall (this=0x741ba0, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fff6f7d7c30)
    at /usr/src/debug/kdebase-workspace-4.5.0/build/kwin/workspace.moc:583
#13 0x00007f94d9b85a1f in QMetaObject::activate (sender=0x742068, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3295
#14 0x00007f94d9b8322e in QObject::event (this=0x742068, e=0x7fff6f7d83d0) at kernel/qobject.cpp:1212
#15 0x00007f94d8d464d4 in QApplicationPrivate::notify_helper (this=0x633400, receiver=0x742068, e=0x7fff6f7d83d0) at kernel/qapplication.cpp:4302
#16 0x00007f94d8d4eaca in QApplication::notify (this=<value optimized out>, receiver=0x742068, e=0x7fff6f7d83d0) at kernel/qapplication.cpp:4185
#17 0x00007f94dccda0b6 in KApplication::notify (this=0x7fff6f7d88e0, receiver=0x742068, event=0x7fff6f7d83d0) at /usr/src/debug/kdelibs-4.5.0/kdeui/kernel/kapplication.cpp:310
#18 0x00007f94d9b71e4c in QCoreApplication::notifyInternal (this=0x7fff6f7d88e0, receiver=0x742068, event=0x7fff6f7d83d0) at kernel/qcoreapplication.cpp:726
#19 0x00007f94d9b9d0c9 in sendEvent (this=0x633df0) at kernel/qcoreapplication.h:215
#20 QTimerInfoList::activateTimers (this=0x633df0) at kernel/qeventdispatcher_unix.cpp:618
#21 0x00007f94d9b9d8c0 in QEventDispatcherUNIX::processEvents (this=0x612010, flags=...) at kernel/qeventdispatcher_unix.cpp:939
#22 0x00007f94d8de7cbc in QEventDispatcherX11::processEvents (this=0x612010, flags=...) at kernel/qeventdispatcher_x11.cpp:152
#23 0x00007f94d9b71292 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#24 0x00007f94d9b71495 in QEventLoop::exec (this=0x7fff6f7d8820, flags=...) at kernel/qeventloop.cpp:201
#25 0x00007f94d9b7588b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1003
#26 0x00007f94dd594314 in kdemain (argc=<value optimized out>, argv=0x7fff6f7d88e0) at /usr/src/debug/kdebase-workspace-4.5.0/kwin/main.cpp:531
#27 0x00007f94dd18bb7d in __libc_start_main (main=0x400770 <main(int, char**)>, argc=1, ubp_av=0x7fff6f7d8ef8, init=<value optimized out>, fini=<value optimized out>, 
    rtld_fini=<value optimized out>, stack_end=0x7fff6f7d8ee8) at libc-start.c:226
#28 0x0000000000400699 in _start () at ../sysdeps/x86_64/elf/start.S:113

Anyway please read what upstream says [1]. The main problem is very probably the fact GetGLXDRIDrawable returns NULL, which should not happen. Sorry, I do not understand the details, but the bug might be still in kwin if it use the DRI2 drawables incorrectly.

[1] http://lists.freedesktop.org/archives/mesa-dev/2010-July/001638.html
Comment 14 Stefan Dirsch 2010-08-26 13:45:54 UTC
Ok. I understand. That is more likely an application/toolkit bug then. Reassigning back.
Comment 15 Christian Trippe 2011-01-12 21:05:16 UTC
Is this still a problem with KDE 4.6?
Comment 16 Forgotten User kHYb7eJGnH 2011-05-15 08:53:02 UTC
no response to needinfo closing...