Bug 202640

Summary: virus wallpaper freezes plasma
Product: [Plasma] plasma4 Reporter: Benoît Jacob <jacob.benoit.1>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: andresbajotierra, asraniel
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Unspecified   
Latest Commit: Version Fixed In:

Description Benoît Jacob 2009-08-05 15:36:57 UTC
Version:            (using KDE 4.3.0)
Installed from:    Fedora RPMs

Here on fedora 11 with KDE 4.3 RC3 packages, selecting the "Virus" wallpaper in Desktop Settings freezes Plasma.

It is a little hard to trace as running plasma in gdb only gives "no stack" although the plasma process is still alive.

However I was able to get the following backtrace by doing:

$ gdb plasmawallpaperviewer -p virus
> run
... then hit Ctrl+C to send a SIGINT
> bt

resulting backtrace:

#0  0x008c1424 in __kernel_vsyscall ()
#1  0x0020823b in poll () from /lib/libc.so.6
#2  0x004cf43b in g_poll () from /lib/libglib-2.0.so.0
#3  0x004c21ab in ?? () from /lib/libglib-2.0.so.0
#4  0x004c24a3 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#5  0x0216701c in QEventDispatcherGlib::processEvents (this=0x8073e48, flags={i = 36})
    at kernel/qeventdispatcher_glib.cpp:327
#6  0x033e44b5 in QGuiEventDispatcherGlib::processEvents (this=0x8073e48, flags={i = 36})
    at kernel/qguieventdispatcher_glib.cpp:202
#7  0x0213ab79 in QEventLoop::processEvents (this=0xbffff464, flags={i = 36}) at kernel/qeventloop.cpp:149
#8  0x0213afca in QEventLoop::exec (this=0xbffff464, flags={i = 0}) at kernel/qeventloop.cpp:201
#9  0x0213d43f in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#10 0x03345237 in QApplication::exec () at kernel/qapplication.cpp:3525
#11 0x0804e3c9 in _start ()
Comment 1 Dario Andres 2009-08-05 18:59:44 UTC
- Do you experience the same freeze using "plasmawallpaperviewer" ? 
The backtrace shows a normal event loop

You can try to attach gdb to the real plasma, using the command "gdb --pid PID", where PID is the PID of "plasma-desktop" (run "pidof plasma-desktop" to get it)

Thanks
Comment 2 Benoît Jacob 2009-08-05 22:54:11 UTC
Yes, the freezes also occurs in plasmawallpaperviewer, the backtrace that I attached in the original message was taken on the plasmawallpaperviewer as I said.

I followed your advice and enabled Virus in the actual plasma-desktop and used gdb to trace into it, and got this hopefully more interesting backtrace. Sorry there seems to be a problem with the -debuginfo fedora package for kdeplasma-addons at the moment, tell me if it's really important that I get the missing entry.

Loaded symbols for /usr/lib/kde4/plasma_wallpaper_virus.so                                                              
0x0204922a in QThread::isFinished (this=0x91f28d8) at thread/qthread.cpp:419                                            
419     {                                                                                                               
Missing separate debuginfos, use: debuginfo-install kdebase-workspace-4.2.98-3.fc11.i586                                
(gdb) bt                                                                                                                
#0  0x0204922a in QThread::isFinished (this=0x91f28d8) at thread/qthread.cpp:419                                        
#1  0x01137900 in ?? () from /usr/lib/kde4/plasma_wallpaper_virus.so                                                    
#2  0x0260762c in KDialog::setButtons(QFlags<KDialog::ButtonCode>) () from /usr/lib/libkdeinit4_plasma-desktop.so       
#3  0x026070cb in KDialog::setButtons(QFlags<KDialog::ButtonCode>) () from /usr/lib/libkdeinit4_plasma-desktop.so       
#4  0x021522b3 in QMetaObject::activate (sender=0x92d09f8, from_signal_index=27, to_signal_index=27, argv=0xbfe01c68)   
    at kernel/qobject.cpp:3113                                                                                          
#5  0x02152f12 in QMetaObject::activate (sender=0x92d09f8, m=0x3babf44, local_signal_index=0, argv=0xbfe01c68)          
    at kernel/qobject.cpp:3187                                                                                          
#6  0x0382efb3 in QDialog::finished (this=0x92d09f8, _t1=1) at .moc/release-shared/moc_qdialog.cpp:133                  
#7  0x038301fc in QDialog::done (this=0x92d09f8, r=1) at dialogs/qdialog.cpp:541                                        
#8  0x0382ee2c in QDialog::accept (this=0x92d09f8) at dialogs/qdialog.cpp:556                                           
#9  0x03cf7903 in KDialog::slotButtonClicked(int) () from /usr/lib/libkdeui.so.5                                        
#10 0x03cf9e79 in KDialog::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5                   
#11 0x03dc166a in KPageDialog::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5               
#12 0x03ce4bda in KConfigDialog::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5             
#13 0x0260705a in KDialog::setButtons(QFlags<KDialog::ButtonCode>) () from /usr/lib/libkdeinit4_plasma-desktop.so       
#14 0x021522b3 in QMetaObject::activate (sender=0x8e91ef8, from_signal_index=4, to_signal_index=4, argv=0xbfe01ef8)     
    at kernel/qobject.cpp:3113                                                                                          
#15 0x02152f12 in QMetaObject::activate (sender=0x8e91ef8, m=0x222c6d8, local_signal_index=0, argv=0xbfe01ef8)          
    at kernel/qobject.cpp:3187                                                                                          
#16 0x02154ec3 in QSignalMapper::mapped (this=0x8e91ef8, _t1=4) at .moc/release-shared/moc_qsignalmapper.cpp:95         
#17 0x0215575d in QSignalMapper::map (this=0x8e91ef8, sender=0x92cacc8) at kernel/qsignalmapper.cpp:266                 
#18 0x0215593e in QSignalMapper::map (this=0x8e91ef8) at kernel/qsignalmapper.cpp:257                                   
#19 0x0215617b in QSignalMapper::qt_metacall (this=0x8e91ef8, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xbfe020c8)   
    at .moc/release-shared/moc_qsignalmapper.cpp:81                                                                     
#20 0x021522b3 in QMetaObject::activate (sender=0x92cacc8, from_signal_index=29, to_signal_index=30, argv=0xbfe020c8)   
    at kernel/qobject.cpp:3113                                                                                          
#21 0x02152728 in QMetaObject::activate (sender=0x92cacc8, m=0x3bb3b64, from_local_signal_index=2,                      
    to_local_signal_index=3, argv=0xbfe020c8) at kernel/qobject.cpp:3207                                                
#22 0x039ce8f1 in QAbstractButton::clicked (this=0x92cacc8, _t1=false)                                                  
    at .moc/release-shared/moc_qabstractbutton.cpp:200                                                                  
#23 0x036f8e29 in QAbstractButtonPrivate::emitClicked (this=0x92cf468) at widgets/qabstractbutton.cpp:543               
---Type <return> to continue, or q <return> to quit---                                                                  
#24 0x036faa84 in QAbstractButtonPrivate::click (this=0x92cf468) at widgets/qabstractbutton.cpp:536                     
#25 0x036fad11 in QAbstractButton::mouseReleaseEvent (this=0x92cacc8, e=0xbfe026c0) at widgets/qabstractbutton.cpp:1115 
#26 0x0339a05f in QWidget::event (this=0x92cacc8, event=0xbfe026c0) at kernel/qwidget.cpp:7549                          
#27 0x036f8cce in QAbstractButton::event (this=0x92cacc8, e=0x8e91f88) at widgets/qabstractbutton.cpp:1077              
#28 0x037a2ccd in QPushButton::event (this=0x92cacc8, e=0xbfe026c0) at widgets/qpushbutton.cpp:662                      
#29 0x033453b4 in QApplicationPrivate::notify_helper (this=0x8b064c0, receiver=0x92cacc8, e=0xbfe026c0)
    at kernel/qapplication.cpp:4056
#30 0x0334d31b in QApplication::notify (this=0x8aff098, receiver=0x92cacc8, e=0xbfe026c0)
    at kernel/qapplication.cpp:3758
#31 0x03d90a1a in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#32 0x0213c58b in QCoreApplication::notifyInternal (this=0x8aff098, receiver=0x92cacc8, event=0xbfe026c0)
    at kernel/qcoreapplication.cpp:610
#33 0x0334c3de in QCoreApplication::sendSpontaneousEvent (event=<value optimized out>, receiver=<value optimized out>)
    at ../../src/corelib/kernel/qcoreapplication.h:216
#34 QApplicationPrivate::sendMouseEvent (event=<value optimized out>, receiver=<value optimized out>)
    at kernel/qapplication.cpp:2924
#35 0x033ba870 in QETWidget::translateMouseEvent (this=0x92d09f8, event=0xbfe03d0c) at kernel/qapplication_x11.cpp:4404
#36 0x033b9d03 in QApplication::x11ProcessEvent (this=0x8aff098, event=0xbfe03d0c) at kernel/qapplication_x11.cpp:3423
#37 0x033e4dd2 in x11EventSourceDispatch (s=0x8b0ff68, callback=0, user_data=0x0)
    at kernel/qguieventdispatcher_glib.cpp:146
#38 0x004becf8 in g_main_dispatch (context=<value optimized out>) at gmain.c:1824
#39 IA__g_main_context_dispatch (context=<value optimized out>) at gmain.c:2377
#40 0x004c2370 in g_main_context_iterate (context=0x8b0f490, block=<value optimized out>, dispatch=1, self=0x8b05f98)
    at gmain.c:2455
#41 0x004c24a3 in IA__g_main_context_iteration (context=0x8b0f490, may_block=1) at gmain.c:2518
#42 0x0216701c in QEventDispatcherGlib::processEvents (this=0x8ae9e50, flags={i = 36})
    at kernel/qeventdispatcher_glib.cpp:327
#43 0x033e44b5 in QGuiEventDispatcherGlib::processEvents (this=0x8ae9e50, flags={i = 36})
    at kernel/qguieventdispatcher_glib.cpp:202
#44 0x0213ab79 in QEventLoop::processEvents (this=0xbfe04004, flags={i = 36}) at kernel/qeventloop.cpp:149
#45 0x0213afca in QEventLoop::exec (this=0xbfe04004, flags={i = 0}) at kernel/qeventloop.cpp:201
#46 0x0213d43f in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
---Type <return> to continue, or q <return> to quit---
#47 0x03345237 in QApplication::exec () at kernel/qapplication.cpp:3525
#48 0x026183ed in kdemain () from /usr/lib/libkdeinit4_plasma-desktop.so
#49 0x080486fb in _start ()
Current language:  auto; currently c++
Comment 3 Benoît Jacob 2009-08-05 22:55:23 UTC
Note: this happens just after I press the "OK" button in Desktop Settings dialog.
Comment 4 Benoît Jacob 2009-08-05 23:03:48 UTC
OK, it was easy to compensate for the ?? in the backtrace. It freezes when virus calls isFinished(). Grepping through the source code, there is only one isFinished() call in virus, it is at line 57 in virus.cpp:

Virus::~Virus()
{
    alife.exit(0);
    while(!alife.isFinished()) ;
}

So this is presumably when the destructor is called on the virus that is embedded in the Desktop Settings dialog, that is destroyed when I click "OK".

Looking further into the problem, it is waiting for "alife" to finish, so let's look in alife.cpp:

Alife::~Alife(){
    resetLife();
}

void Alife::resetLife(){
    mutex.lock();
    if(inited()){
        while( !m_livingCells.isEmpty() ){
            struct cell* cell = m_livingCells.takeFirst();
            delete [] cell->code;
        }

        delete []m_cells[0];
        delete []m_cells;
        m_cells = 0;
    }
    mutex.unlock();
    //qDebug() << "life reseted";
}

It looks like this mutex locking could easily what prevents "alife" from finishing!

I'll leave it to the Virus author from now ;)
Comment 5 Beat Wolf 2009-08-06 20:15:21 UTC
SVN commit 1008032 by beatwolf:

possible fix for 
CCBUG:202640


 M  +5 -4      alife.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1008032
Comment 6 Benoît Jacob 2009-08-07 00:58:50 UTC
SVN commit 1008125 by bjacob:

actual fix for
CCBUG:202640



 M  +1 -1      virus.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1008125
Comment 7 Benoît Jacob 2009-08-07 03:03:26 UTC
backported to 4.3 branch
Comment 8 Benoît Jacob 2009-08-07 03:05:44 UTC
Beat: also note that your commit had no chance at all of making a difference, as only the thread that locked a mutex is able to unlock it, that's the whole point of mutexes. Also note that your commit adds some unwanted blurbs apparently caused by drag&drop into kate. By the way you also have a lot of tabs, please indent only with spaces.
Comment 9 Beat Wolf 2009-08-07 08:14:24 UTC
So why did you backport the fix to 4.3 and close the bugreport if it does not fix the problem? but it's actually good, because i couldn't imagine a way this could have solved the problem, but needed you to test it anyway. I don't know when i'm online over the weekend, but hope to see you on IRC monday or so to solve the bug (i will have a look at the code until then anyway and probably improve codestyle on the same time).
Comment 10 Beat Wolf 2009-08-07 08:24:36 UTC
nevermind, i saw that you commited the real fix.
Thanks for the critique, even though i completely understand semaphores it's true that i should perhaps read some more about how to use qt threads. I started with the first batch of style fixes (tabs) and will do the rest asap (if else etc style).
thanks for the fix and have a nice weekend!