Bug 53575 - KDirWatch crash (was: Autoproject part crashes invoking the "add files to target" dialog)
Summary: KDirWatch crash (was: Autoproject part crashes invoking the "add files to tar...
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: SVN
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-29 13:23 UTC by Hamish Rodda
Modified: 2003-02-20 07:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed Bugfix (362 bytes, patch)
2003-02-10 11:59 UTC, Josef Weidendorfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hamish Rodda 2003-01-29 13:23:21 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 2.95 (debian)
OS:          Linux

Upon invoking the "add files" action on a target in the automake part, gideon will most likely crash on my computer.  This appears to be due to KDirWatch, but I'm submitting it here first just in case someone can do a better interpretation than I.

The backtrace:
[New Thread 16384 (LWP 2218)]
0x41533a39 in wait4 () from /lib/libc.so.6
#0  0x41533a39 in wait4 () from /lib/libc.so.6
#1  0x415a6ba0 in sys_sigabbrev () from /lib/libc.so.6
#2  0x413c9061 in waitpid () from /lib/libpthread.so.0
#3  0x40ba247a in KCrash::defaultCrashHandler (sig=11) at kcrash.cpp:235
#4  0x414c0898 in sigaction () from /lib/libc.so.6
#5  0x41106d0a in QString::operator+= () from /usr/lib/libqt-mt.so.3
#6  0x407471ed in KDirWatchPrivate::removeEntry (this=0x824fd68, instance=0x0,
    _path=@0x873328c, sub_entry=0x0) at ../../kdecore/kdebug.h:178
#7  0x40749114 in KDirWatchPrivate::slotRemoveDelayed (this=0x824fd68)
    at kdirwatch.cpp:939
#8  0x4074c8a9 in KDirWatchPrivate::qt_invoke (this=0x824fd68, _id=5, 
    _o=0xbfffed30) at kdirwatch_p.moc:91
#9  0x40ee7a59 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#10 0x41147d53 in QSignal::signal () from /usr/lib/libqt-mt.so.3
#11 0x40efd105 in QSignal::activate () from /usr/lib/libqt-mt.so.3
#12 0x40f02583 in QSingleShotTimer::event () from /usr/lib/libqt-mt.so.3
#13 0x40e95a93 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#14 0x40e95894 in QApplication::notify () from /usr/lib/libqt-mt.so.3
#15 0x40b1fb3a in KApplication::notify (this=0xbffff990, receiver=0x848ae00,
    event=0xbfffefa4) at kapplication.cpp:454
#16 0x40e78303 in QEventLoop::activateTimers () from /usr/lib/libqt-mt.so.3
#17 0x40e5a33c in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#18 0x40ea71fe in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#19 0x40e95c4a in QApplication::enter_loop () from /usr/lib/libqt-mt.so.3
#20 0x4100f4f1 in QDialog::exec () from /usr/lib/libqt-mt.so.3
#21 0x41c37c0b in AutoProjectWidget::slotAddExistingFile (this=0x843c5a0)
    at autoprojectwidget.cpp:879
#22 0x41c3d979 in AutoProjectWidget::qt_invoke (this=0x843c5a0, _id=59,
    _o=0xbffff334) at autoprojectwidget.moc:153
#23 0x40ee7a59 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#24 0x40ee799e in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#25 0x4114ef10 in QButton::clicked () from /usr/lib/libqt-mt.so.3
#26 0x40f52d47 in QButton::mouseReleaseEvent () from /usr/lib/libqt-mt.so.3
#27 0x40f122a6 in QWidget::event () from /usr/lib/libqt-mt.so.3
#28 0x40e95a93 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#29 0x40e9553b in QApplication::notify () from /usr/lib/libqt-mt.so.3
#30 0x40b1fb3a in KApplication::notify (this=0xbffff990, receiver=0x844a9c8, 
    event=0xbffff5ec) at kapplication.cpp:454
#31 0x40e4a624 in QETWidget::translateMouseEvent () from /usr/lib/libqt-mt.so.3
#32 0x40e48918 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#33 0x40e59e02 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#34 0x40ea71fe in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#35 0x40ea715b in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#36 0x40e95bea in QApplication::exec () from /usr/lib/libqt-mt.so.3
#37 0x08064649 in main (argc=7, argv=0xbffffaf4) at main.cpp:78

I have determined that the dialog is in the process of being created when it crashes (indeed you see a flicker of the dialog on the screen before it disappears).  The one time it worked for me while testing some potential fixes, I got the following warning:

kio (KDirWatch): WARNING: KDirWatch::removeDir can't handle '???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

So, KDirWatch seems to be getting some bad info somewhere.  (I'd like to valgrind this but my valgrind says it can't handle signal 252, I think my glibc is too new).  Here's a more complete debug log from the KDir* stuff from just before the crash:

kio (KDirLister): +KDirLister
kio (KDirLister): [bool KDirLister::openURL(const KURL &, bool = false, bool = false)] file:/opt/kde/kdevelop/parts/autoproject/ keep=false reload=false
kio (KDirListerCache): [void KDirListerCache::listDir(KDirLister *, const KURL &, bool, bool)] 0x873c740 url=file:/opt/kde/kdevelop/parts/autoproject keep=false reload=false
kio (KDirListerCache): [void KDirListerCache::stop(KDirLister *)] lister: 0x873c740
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *)] 0x873c740
kio (KDirListerCache): listDir: Entry in cache: file:/opt/kde/kdevelop/parts/autoproject
kio (KDirWatch): Cancelled FAM (Req 1) for /opt/kde/kdevelop/parts/autoproject
kio (KDirWatch): Removed Dir /opt/kde/kdevelop/parts/autoproject [KDirWatch-1]
kio (KDirWatch): Added Dir /opt/kde/kdevelop/parts/autoproject [KDirWatch-1]
kio (KDirWatch):  Setup FAM (Req 12) for /opt/kde/kdevelop/parts/autoproject
kio (KDirLister): [bool KDirLister::openURL(const KURL &, bool = false, bool = false)] file:/opt/kde/kdevelop/parts/autoproject/ keep=false reload=true
kio (KDirListerCache): [void KDirListerCache::listDir(KDirLister *, const KURL &, bool, bool)] 0x873c740 url=file:/opt/kde/kdevelop/parts/autoproject keep=false reload=true
kio (KDirListerCache): [void KDirListerCache::stop(KDirLister *)] lister: 0x873c740
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *)] 0x873c740
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *, const KURL &, bool)] 0x873c740 url: file:/opt/kde/kdevelop/parts/autoproject
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *, const KURL &, bool)] 0x873c740 item moved into cache: file:/opt/kde/kdevelop/parts/autoproject
kio (KDirListerCache): listDir: Entry not in cache or reloaded: file:/opt/kde/kdevelop/parts/autoproject
kio (KDirWatch): Added already watched Entry /opt/kde/kdevelop/parts/autoproject (now 1 clients) [KDirWatch-1]
kio (KDirLister): [bool KDirLister::openURL(const KURL &, bool = false, bool = false)] file:/home/hamish/source/med/src/communications/protocols/high-level/hl7/ keep=false reload=false
kio (KDirListerCache): [void KDirListerCache::listDir(KDirLister *, const KURL &, bool, bool)] 0x873c740 url=file:/home/hamish/source/med/src/communications/protocols/high-level/hl7 keep=false reload=false
kio (KDirListerCache): [void KDirListerCache::stop(KDirLister *)] lister: 0x873c740
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *)] 0x873c740
kio (KDirListerCache): [void KDirListerCache::forgetDirs(KDirLister *, const KURL &, bool)] 0x873c740 url: file:/opt/kde/kdevelop/parts/autoproject
kio (KDirListerCache): listDir: Entry not in cache or reloaded: file:/home/hamish/source/med/src/communications/protocols/high-level/hl7
kio (KDirWatch): Added Dir /home/hamish/source/med/src/communications/protocols/high-level/hl7 [KDirWatch-1]
kio (KDirWatch):  Setup FAM (Req 13) for /home/hamish/source/med/src/communications/protocols/high-level/hl7
kio (KDirWatch): Cancelled FAM (Req 12) for /opt/kde/kdevelop/parts/autoproject
kio (KDirWatch): Removed Dir /opt/kde/kdevelop/parts/autoproject

So, is this not the automake part's fault? Can I reassign this to kio?

Thanks,
Hamish.
Comment 1 Hamish Rodda 2003-01-29 13:29:04 UTC
BTW The wizard seems not to have picked up that I am using the latest CVS versions of both 
gideon and kdelibs. 
Comment 2 Hamish Rodda 2003-01-30 09:21:21 UTC
My index of suspicion of the KDir* stuff has risen, so I'm moving this to kio.  I also 
forgot to mention that the crash happens much less frequently when my computer is 
under heavy load, so this is likely to be some sort of race condition. 
 
Commenting out line 614 of kdirwatch.cpp like so: 
 
void KDirWatchPrivate::removeEntry( KDirWatch* instance, 
				    const QString& _path, Entry* sub_entry ) 
{ 
  Entry* e = entry(_path); 
  if (!e) { 
	//kdWarning(7001) << "KDirWatch::removeDir can't handle '" << _path << "'" << 
endl; 
	return; 
 
 
prevents the crash... 
Comment 3 Josef Weidendorfer 2003-02-10 11:59:47 UTC
Created attachment 924 [details]
Proposed Bugfix

Hi,

please can you try out this patch?
The removeList is only allowed to contain an entry to be removed at most once.
It's possible that this is the reason for your crash.
If it's not - that was still a bug and should be fixed.
The removeList should be a QStringList containing the paths to be removed.
Thus, your crash can't happen.
Comment 4 Hamish Rodda 2003-02-11 13:23:01 UTC
This patch solves the problem for me, thanks!  Shall I commit & close the bug? 
 
Thanks, Hamish. 
Comment 5 Josef Weidendorfer 2003-02-13 14:44:28 UTC
Yes. This would be nice. Can you backport this to the 3.1 branch, too? 
Josef 
Comment 6 Hamish Rodda 2003-02-20 07:27:30 UTC
Subject: KDE_3_1_BRANCH: kdelibs/kio/kio

CVS commit by rodda: 

Backport Josef's fix for bug 53575

CCMAIL:53575-done@bugs.kde.org


  M +2 -0      kdirwatch.cpp   1.87.2.3


--- kdelibs/kio/kio/kdirwatch.cpp  #1.87.2.2:1.87.2.3
@@ -625,4 +625,6 @@ void KDirWatchPrivate::removeEntry( KDir
 
   if (delayRemove) {
+    // removeList is allowed to contain any entry at most once
+    if (removeList.findRef(e)==-1)
     removeList.append(e);
     // now e->isValid() is false