Bug 201404 - Crash in deconstructor of PlastikButton
Summary: Crash in deconstructor of PlastikButton
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR crash
Target Milestone: ---
Assignee: Sandro Giessl
URL:
Keywords:
: 201521 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-07-25 00:07 UTC by Markus Knetschke
Modified: 2009-08-21 09:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Knetschke 2009-07-25 00:07:28 UTC
Application that crashed: kwin
Version of the application: 4.3.61 (KDE 4.3.61 (KDE 4.4 >= 20090717)) "release 3"
KDE Version: 4.3.61 (KDE 4.3.61 (KDE 4.4 >= 20090717)) "release 3"
Qt Version: 4.5.2
Operating System: Linux 2.6.27.25-0.1-pae i686
Distribution: "openSUSE 11.1 (i586)"

What I was doing when the application crashed:
After closing Wow (running in window mode) kwin crashed...

I use the nvidia driver with two screens in Twinview mode

 -- Backtrace:
Application: KWin (kwin), signal: Segmentation fault
[KCrash Handler]
#6  ~QWidgetPrivate (this=0x891a468) at ../../src/corelib/arch/qatomic_i386.h:132
#7  0xb7125e5d in ~QAbstractButtonPrivate (this=0x891a468) at widgets/qabstractbutton_p.h:62
#8  0xb6b15dd1 in ~QObject (this=0x88fcf60) at kernel/qobject.cpp:857
#9  0xb6ddc80f in ~QWidget (this=0x88fcf60) at kernel/qwidget.cpp:1380
#10 0xb7123d01 in ~QAbstractButton (this=0x88fcf60) at widgets/qabstractbutton.cpp:601
#11 0xb7f06b11 in ~KCommonDecorationButton (this=0x88fcf60) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/lib/kcommondecoration.cpp:926
#12 0xb2012a22 in ~PlastikButton (this=0x88fcf60) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/clients/plastik/plastikbutton.cpp:65
#13 0xb7f080a8 in ~KCommonDecoration (this=0x84ea348) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/lib/kcommondecoration.cpp:65
#14 0xb20107e5 in ~PlastikClient (this=0x84ea348) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/clients/plastik/plastikclient.cpp:61
#15 0xb7f0a021 in ~KCommonDecorationWrapper (this=0x88dcf20) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/lib/kcommondecoration_p.cpp:43
#16 0xb7f3d315 in KWin::Client::destroyDecoration (this=0x890f018) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/client.cpp:360
#17 0xb7f3e99b in KWin::Client::releaseWindow (this=0x890f018, on_shutdown=false) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/client.cpp:231
#18 0xb7f61c5b in KWin::Client::unmapNotifyEvent (this=0x890f018, e=0xbf9a4c2c) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/events.cpp:796
#19 0xb7f63647 in KWin::Client::windowEvent (this=0x890f018, e=0xbf9a4c2c) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/events.cpp:642
#20 0xb7f63ab4 in KWin::Workspace::workspaceEvent (this=0x822a6b8, e=0xbf9a4c2c) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/events.cpp:319
#21 0xb7f4a522 in KWin::Application::x11EventFilter (this=0xbf9a4f44, e=0xbf9a4c2c) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/main.cpp:362
#22 0xb6ded88e in qt_x11EventFilter (ev=0xbf9a4c2c) at kernel/qapplication_x11.cpp:375
#23 0xb6e0010f in QApplication::x11ProcessEvent (this=0xbf9a4f44, event=0xbf9a4c2c) at kernel/qapplication_x11.cpp:3269
#24 0xb6e2b5ca in x11EventSourceDispatch (s=0x807eee8, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#25 0xb4da09c8 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#26 0xb4da4083 in ?? () from /usr/lib/libglib-2.0.so.0
#27 0xb4da4241 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#28 0xb6b2a8d8 in QEventDispatcherGlib::processEvents (this=0x807be78, flags={i = -1080406552}) at kernel/qeventdispatcher_glib.cpp:327
#29 0xb6e2acc5 in QGuiEventDispatcherGlib::processEvents (this=0x807be78, flags={i = -1080406504}) at kernel/qguieventdispatcher_glib.cpp:202
#30 0xb6afd78a in QEventLoop::processEvents (this=0xbf9a4e90, flags={i = -1080406440}) at kernel/qeventloop.cpp:149
#31 0xb6afdbd2 in QEventLoop::exec (this=0xbf9a4e90, flags={i = -1080406376}) at kernel/qeventloop.cpp:201
#32 0xb6b00079 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#33 0xb6d8a677 in QApplication::exec () at kernel/qapplication.cpp:3525
#34 0xb7f4cda3 in kdemain (argc=3, argv=0xbf9a5124) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/kwin/main.cpp:527
#35 0x080487c2 in main (argc=-1218492992, argv=0x0) at /usr/src/debug/kdebase-workspace-4.3.61svn998540/build/kwin/kwin_dummy.cpp:3

Reported using DrKonqi
Comment 1 Thomas Lübking 2009-07-25 00:20:09 UTC
segfaults during the destruction of a deco button
-> plastik deco | KCommonDecorationButton | Qt issue

a) is this reproducable?
b) ...with another decoration than plastik?
Comment 2 Markus Knetschke 2009-07-26 23:32:20 UTC
it happens only with plastik deco every 6-9 times... so only randomly
Comment 3 Martin Flöser 2009-07-29 13:31:22 UTC
*** Bug 201521 has been marked as a duplicate of this bug. ***
Comment 4 Sandro Giessl 2009-08-10 11:34:33 UTC
> SVN commit 1009552 by giessl:
> 
> fix mem leak in plastik.
> 
> is the leaking QTimer related to the crash? (I'm unable to reproduce it myself)
Comment 5 Thomas Lübking 2009-08-10 15:21:23 UTC
nope (but good you fixed it anyway)

i'd rather say it's for a double deletion attempt:
PlastikClient::createButton() creates PlastikButtons as KCommonDecorationButton's, passing itself as parent.
KCommonDecorationButton takes the parameter and creates a QAbstractButton passing PlastikClient::widget() as QObject parent.
Nevertheless KCommonDecoration::~() attempts to delete the m_button KCommonDecorationButton *'s

This fails as parented QObject are also deleted by Qt moc code, invalidating the mem area.

-> possible solutions:
a) don't delete m_button's in KCommonDecoration::~()

b) make m_button QPointer<KCommonDecorationButton>, they'll then be NULL after deleted by moc. Don't forget to assign them NULL in KCommonDecoration::~() as well!

c) don't parent them in the KCommonDecorationConstructor (the  ":QAbstractButton(parent->widget())," is dangerous anyway as the pointer isn't guaranteed to be not NULL, use a reference instead or use "parent?parent->widget():0")

My personal suggestion would be and adjusted* b) (and fix c!), reason:
- you probably don't want to change the API/ABI of KCommonDecoration, so you need to handle the parent==0 case
- if parent==0 you cannot rely on moc and /must/ delete the buttons yourself (or have the inheritors do)

*unfortunately changing KCommonDecorationButton* to QPointer<KCommonDecorationButton> will (likely...) break ABI therefore you'll have to go the hard path and connect the destroyed() signal of the m_button's to your own internal private little deletion slot, setting the m_button[] reference (iterate and compare pointers) to NULL ;-)

(though in case you can ensure parent!=0 you can just skip deletion like a)

as you maintain both, you may take your choice ;-P
Comment 6 Thomas Lübking 2009-08-10 15:25:51 UTC
ps: for the same reason you should no delete m_previewWidget in the deconstructor either...
Comment 7 Sandro Giessl 2009-08-21 09:25:59 UTC
SVN commit 1013904 by giessl:

Prevent double deletion of widgets that are managed by their QObject parents
but need to be managed by KCommonDecoration as well.
Thanks a lot Thomas, I went for "adjusted* b) (and fix c!)".

Feedback regarding 201404 would be great.

BUG: 201404


 M  +53 -1     kcommondecoration.cpp  
 M  +4 -0      kcommondecoration.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1013904