Bug 291390

Summary: Kwin crashes when "opengl2 shaders" are disabled and "explosion" effect is enabled
Product: [Plasma] kwin Reporter: Nikola Schnelle <n.schnelle>
Component: effects-variousAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: n.schnelle
Priority: NOR    
Version: 4.8.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.8.0
Attachments: New crash information added by DrKonqi
New crash information added by DrKonqi

Description Nikola Schnelle 2012-01-12 19:15:48 UTC
Version:           4.8.0 (using Devel) 
OS:                Linux

Kwin crashes and disables effects if user try to enable "explosion" effect while opengl2 shaders are disabled. 

Reproducible: Always

Steps to Reproduce:
1) Uncheck "use opengl2 shades"
2) Enable "explosion" effect

Actual Results:  
Kwin crashes.

Expected Results:  
Kwin not crashing (notification that "explosion" effect cannot be enabled without kwin crashing).
Comment 1 Martin Flöser 2012-01-12 19:25:03 UTC
we need a backtrace for a crash
Comment 2 Nikola Schnelle 2012-01-12 20:05:58 UTC
Created attachment 67753 [details]
New crash information added by DrKonqi

kwin (4.7.97 (4.8 RC2 (4.7.97)) on KDE Platform 4.7.97 (4.8 RC2 (4.7.97) using Qt 4.7.4

- What I was doing when the application crashed:

Enabled "explosion" desktop effect while opengl2 shaders were disabled

-- Backtrace (Reduced):
#7  0xb64c8d1b in KWin::GLShader::uniformLocation (this=0x0, name=0xad62128d "screenTransformation") at ../../../kwin/libkwineffects/kwinglutils.cpp:429
#8  0xb64c955e in KWin::GLShader::getUniformMatrix4x4 (this=0x0, name=0xad62128d "screenTransformation") at ../../../kwin/libkwineffects/kwinglutils.cpp:584
#9  0xad600e40 in KWin::ExplosionEffect::paintWindow (this=0xa1b8fb8, w=0x985e630, mask=38, region=..., data=...) at ../../../kwin/effects/explosion/explosion.cpp:150
#10 0xb76cb4c8 in KWin::EffectsHandlerImpl::paintWindow (this=0x9a78018, w=0x985e630, mask=38, region=..., data=...) at ../../kwin/effects.cpp:246
#11 0xad58c74c in KWin::FadeEffect::paintWindow (this=0x9ad6fc8, w=0x985e630, mask=38, region=..., data=...) at ../../../kwin/effects/fade/fade.cpp:150
Comment 3 Nikola Schnelle 2012-01-12 20:10:01 UTC
Created attachment 67754 [details]
New crash information added by DrKonqi

kwin (4.7.97 (4.8 RC2 (4.7.97)) on KDE Platform 4.7.97 (4.8 RC2 (4.7.97) using Qt 4.7.4

- What I was doing when the application crashed:

Kwin crashed when "opengl2 shaders" are disabled and "explosion" effect is enabled

-- Backtrace (Reduced):
#7  0xb64f9d1b in KWin::GLShader::uniformLocation (this=0x0, name=0xad63428d "screenTransformation") at ../../../kwin/libkwineffects/kwinglutils.cpp:429
#8  0xb64fa55e in KWin::GLShader::getUniformMatrix4x4 (this=0x0, name=0xad63428d "screenTransformation") at ../../../kwin/libkwineffects/kwinglutils.cpp:584
#9  0xad613e40 in KWin::ExplosionEffect::paintWindow (this=0xa339af8, w=0xa4c36d0, mask=38, region=..., data=...) at ../../../kwin/effects/explosion/explosion.cpp:150
#10 0xb76fc4c8 in KWin::EffectsHandlerImpl::paintWindow (this=0xa278b00, w=0xa4c36d0, mask=38, region=..., data=...) at ../../kwin/effects.cpp:246
#11 0xad59f646 in KWin::FadeEffect::paintWindow (this=0xa2e5a88, w=0xa4c36d0, mask=38, region=..., data=...) at ../../../kwin/effects/fade/fade.cpp:140
Comment 4 Martin Flöser 2012-01-12 20:19:23 UTC
please try this patch:

diff --git a/kwin/effects/explosion/explosion.cpp b/kwin/effects/explosion/explosion.cpp
index bdff254..a2e523f 100644
--- a/kwin/effects/explosion/explosion.cpp
+++ b/kwin/effects/explosion/explosion.cpp
@@ -136,7 +136,7 @@ void ExplosionEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
 {
     // Make sure we have OpenGL compositing and the window is vidible and not a
     //  special window
-    bool useshader = (mValid && mWindows.contains(w));
+    bool useshader = (mValid && mWindows.contains(w)) && ShaderManager::instance()->isValid();
     if (useshader) {
         double maxscaleadd = 1.5f;
         double scale = 1 + maxscaleadd * mWindows[w];
Comment 5 Nikola Schnelle 2012-01-12 20:39:50 UTC
I am sorry, I am still relativly new to linux so I still don't know how to patch something :( If it is not complicated, please point me to some patching guide/wiki and I will try tommorow. I am on Kubuntu 11.10 KDE 4.8rc2.
Comment 6 Martin Flöser 2012-01-13 08:07:37 UTC
Git commit edd5726eb6f53fbffedadff68a913f07431d40db by Martin Gräßlin.
Committed on 13/01/2012 at 09:01.
Pushed by graesslin into branch 'KDE/4.8'.

Check whether the ShaderManager is valid in Explosion effect

The effect did not check whether the ShaderManager is valid causing
a null pointer access when trying to use the shader.

Additionally this change moves the Shader init into the close window
slot as close window referrenced windows without checking whether the
effect would work. If the effect would not work each closed window
would be referrenced without any chance to being unreffed again as this
code is in a block checking whether the effect is valid.
FIXED-IN: 4.8.0

M  +9    -2    kwin/effects/explosion/explosion.cpp

http://commits.kde.org/kde-workspace/edd5726eb6f53fbffedadff68a913f07431d40db