KIO::mimetype sync call in DocumentController::openDocumentInternal hazardous
mail at milianw.de
Tue Sep 28 11:18:45 UTC 2010
Milian Wolff, 26.09.2010:
> anyone ever got this and went mad:
> ASSERT: "!documents.contains(url) || documents[url]==doc" in file
> /home/milian/projects/kde4/kdevplatform/shell/documentcontroller.cpp, line
> I found a way to get it reproducible, for me it's the second time I try
> something like this:
> kdevelop -d kate
> first run works, second will fail.
> Lots of debug output later I found out what the reason is:
> openDocumentInternal is called twice, within the same thread, without the
> first returning. The reason for that? KIO::mimetype job executed
> a) mimeType->is( "application/octet-stream" ) is most probably always true,
> since ->is() honors mimetype inheritance and afaik this is a quite generic
> mimetype that most others inherit. so this should be fixed to ->name() ==
> "application/octet-stream". I'll do this later, but it doesn't fix the real
> b) look at this code:
> // Try harder using KIO. This also allows looking at
> the content of remote files.
> KIO::MimetypeJob* job = KIO::mimetype(url,
> mimeType = KMimeType::mimeType(job->mimetype());
> delete job;
> looks nice, and safe, doesn't it? well, wrong. Let me quote from the
> documentation of KJob exec():
> * Should you indeed call this method, you need to make sure that all
> callers are reentrant,
> * so that events delivered by the inner event loop don't cause non-
> reentrant functions to be
> * called, which usually wreaks havoc.
> indeed, it does wreak havoc here! Somehow the eventloop black-magic leads
> to another call to
> KDevelop::WorkingSet::changedWorkingSet which eventually tries to get the
> same document from the controller again => fail.
> So how can we fix this? Can someone explain how I could make
> openDocumentInternal reentrant? Just by coping with the case the assertion
> currently prevents? I sadly don't see a way to use the safe async KJob api
> here :-S
I just spoke to David Faure, he said that this code should _not_ be required.
KIO::mimetype should only be required for KIO slaves like HTTP where one
cannot rely on the file extension to guess a mimetype.
$ kmimetypefinder sftp://bla/something/read.php
It does not even connect to the host, it just looks at the URL and its
So, david - why did you add this code? I'm tempted to remove it again.
What is left to be done is testing this:
https://bugs.kde.org/show_bug.cgi?id=234644 in a 4.1 build - can someone do
this for me? Otherwise I'll try it tomorrow.
mail at milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 198 bytes
Desc: This is a digitally signed message part.
More information about the KDevelop-devel