problem with KIO::NetAccess and KDirLister/KFileTreeView

Josef Weidendorfer Josef.Weidendorfer at gmx.de
Mon Oct 14 14:40:57 BST 2002


Hi,

I'm unfortunately not able to reproduce. When I create a new Dir in the 
FileSaveAs dialog, I get the following debug output:
...
kio (KDirListerCache): listDir: Entry not in cache or reloaded: 
file:/root/tmp/New Directory
kio (KDirWatch): Added Dir /root/tmp/New Directory [KDirWatch-1]
kio (KDirWatch):  Setup FAM (Req 4) for /root/tmp/New Directory
kio (KDirWatch): Processing FAM event (FAMCreated, New Directory, Req 3)
kio (KDirWatch): KDirWatch-1 emitting created /root/tmp/New Directory
...

Your crash happens around the last line from above is printed...

First for the backtrace: Is it right to say there's a SEGFAULT in 
"QPtrList<KDirWatchPrivate::Client>::next"?

If I suppose the QPtrList is fine when "KDirWatchPrivate::emitEvent"
is called, there's only one thing which can go wrong:
Inside of the loop in emitEvent, the signals (e.g. Created) are emitted,
and the slot of KDirLister/KDirListCache changes the list itself by calling 
removeDir. This way we can have a dangling pointer (Client* c in emitEvent).

To avoid this, I once introduced the flag "delayRemove" (see slotRecan(), STAT 
method). When this flag is set to true, entries aren't removed actually in 
removeEntry(), but put into the "removeList". If you look at the end of 
slotRescan(), you see that "delayRemove" is set to false and entries from the 
removeList are removed.

We have to make this "delayRemove" more general, not only for "slotRescan".
(Michael Brade only used the STAT method and sent me these kind of bugs. So
only STAT got stable :-)
All we have to do is with FAM to set delayRemove to true...
And the best is to do actual removing (using removeList) with a oneshot timer
from the mainLoop...

Actually, the best would be to ask the user of KDirWatch not to do anything 
leading to reentrant calls to KDirWatch in a slot called from KDirWatch.
Then, KDirLister would be the one to blame :-)

TODO: By adding "delayed" event emitting as discussed in previos mails, 
"emitEvent()" never will emit a signal itself, so this would be another way 
for fixing...

Nevertheless, can you try the attached patch ?
Josef





On Monday 14 October 2002 13:56, David Faure wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> ...
> I had this crash again. Seems it happens very often when creating a new
> directory in KFileDialog (using the toolbar button there).
> Open any app, get a "save as" file dialog, type a directory path in the
> topright combobox, enter, then use the toolbar button to create a new dir.
>
> Updated backtrace:
> #5  0x4103e478 in killpg () from /lib/libc.so.6
> #6  0x4027e27f in QPtrList<KDirWatchPrivate::Client>::next (this=0x8bb5e6c)
>     at /mnt/devel/kde/kdecvs/qt-copy/include/qptrlist.h:95
> #7  0x401b266b in KDirWatchPrivate::emitEvent (this=0x8a60820, e=0x8bb5e58,
>     event=2, fileName=@0xbfffd770)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:869
> #8  0x401b315a in KDirWatchPrivate::checkFAMEvent (this=0x8a60820,
>     fe=0x402f9b60) at
> /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:1074 #9  0x401b2a32 in
> KDirWatchPrivate::famEventReceived (this=0x8a60820) at
> /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:987
> #10 0x401b0930 in KDirWatchPrivate::useFAM (this=0x8a60820, e=0x8768d40)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:374
> #11 0x401b1349 in KDirWatchPrivate::addEntry (this=0x8a60820,
>     instance=0x8a607c8, _path=@0xbfffda30, sub_entry=0x0, isDir=true)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:537
> #12 0x401b3c06 in KDirWatch::addDir (this=0x8a607c8, _path=@0xbfffda30,
>     watchFiles=false, recursive=false)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirwatch.cpp:1204
> #13 0x40297030 in KDirListerCache::DirItem::incAutoUpdate (this=0x877e8b8)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirlister_p.h:236
> #14 0x401de617 in KDirListerCache::listDir (this=0x8a60480,
> lister=0x8b064c8, _u=@0xbfffdbd0, _keep=false, _reload=false)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirlister.cpp:300
> #15 0x401e4ec8 in KDirLister::openURL (this=0x8b064c8, _url=@0xbfffdbd0,
>     _keep=false, _reload=false)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kio/kdirlister.cpp:1491
> #16 0x40224f89 in KDirOperator::setURL (this=0x8b831c0,
> _newurl=@0xbfffdc50, clearforward=true)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kfile/kdiroperator.cpp:533
> #17 0x40224510 in KDirOperator::mkdir (this=0x8b831c0,
> directory=@0xbfffdcb0, enterDirectory=true)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kfile/kdiroperator.cpp:354
> #18 0x40224350 in KDirOperator::mkdir (this=0x8b831c0)
>     at /mnt/devel/kde/kdecvs/kdelibs/kio/kfile/kdiroperator.cpp:330
>
> - --
> David FAURE, david at mandrakesoft.com, faure at kde.org
> http://people.mandrakesoft.com/~david/
> Contributing to: http://www.konqueror.org/, http://www.koffice.org/
> Get the latest KOffice - http://download.kde.org/stable/koffice-1.2/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
>
> iD8DBQE9qrDv72KcVAmwbhARAo92AJ4p9uZsQpEmIXYrzi5kCeuZH3/DMACeJzGQ
> 1LO3cvqusFT4+wOCnhDvkKk=
> =0a0C
> -----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdirwatch.patch
Type: text/x-diff
Size: 2478 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021014/bd67237a/attachment.patch>


More information about the kde-core-devel mailing list