Calling finished() after error() in KIO slaves causes data corruption and crashes

David Faure faure at kde.org
Mon Mar 17 09:06:11 GMT 2008


On Sunday 16 March 2008, Vlad wrote:
> Another solution would be to transform the documentation guidance into
> a rule and try to enforce it.

That's how we handled it until now.
All non-crashing slaves do exactly that: emitting nothing else after error().

> However, that is going to be hard 
> because finding existing instances where finished() is called after
> error() is not trivial. Frankly, I can see how the instinct of KIO
> slave writers will be to still call finished() after error(), just to
> be safe and make sure it's finished.

Yes, we could add some robustness there inside slavebase, but I don't
really like "noop" calls, so I guess it would have to print a warning
about "don't do that", too.

> PS: Here's how finished() can end up being called after error() in
> kio_smb_browse.cpp:
> 
> 1) SMBSlave::stat() calls SMBSlave::browse_stat_path(), which calls
> SMBSlave::reportError(), which calls error().
> 2) SMBSlave::stat() calls finished() if SMBSlave::browse_stat_path()
> returns false, which it does when there's an error.

Then 2) is wrong, if stat() knows that SMBSlave::browse_stat_path()
always emits error() on error, then it shouldn't call finished() on error.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list