On Friday 06 July 2012 14:44:30 David Faure wrote:
> Obviously the "delete localSocketModel" in nepomukmainmodel.cpp:82 is the
> problem, I assume because it's used in another thread at the same time.
OK after another look at the code, it's clearly because
nepomukmainmodel.cpp:82 can delete the model that is currently in use by other
threads.
I haven't found how to reliably trigger it though (the code says it should
happen when the local socket gets disconnected, but killing either virtuoso or
nepomukserver doesn't trigger it -- maybe due to my earlier fix in soprano...)
> The -1 file descriptor is weird too, does anyone know the reason for that?
This is the same issue, actually. Closing the connection sets the fd to -1
which makes other threads attempt to read from fd -1. Majorly thread unsafe...
I can't come up with a better solution with the one in the attached patch.
Please comment (and CC me), I'll wait for a +2 before committing.
--
David Faure, [email protected], http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5
diff --git a/libnepomukcore/resource/nepomukmainmodel.cpp b/libnepomukcore/resource/nepomukmainmodel.cpp
index ba2626f..20ebcf6 100644
--- a/libnepomukcore/resource/nepomukmainmodel.cpp
+++ b/libnepomukcore/resource/nepomukmainmodel.cpp
@@ -79,7 +79,11 @@ public:
// we may get disconnected from the server but we don't want to try
// to connect every time the model is requested
if ( forced || (!m_socketConnectFailed && !localSocketClient.isConnected()) ) {
- delete localSocketModel;
+ // Cannot delete the model, other threads might still be using it.
+ // With the API that returns iterators, the only way to do this right would be to
+ // use shared pointers, for refcounting the use of the model.
+ // Meanwhile, better leak (on rare occasions) than crash.
+ //delete localSocketModel;
localSocketModel = 0;
localSocketClient.disconnect();
QString socketName = KGlobal::dirs()->locateLocal( "socket", "nepomuk-socket" );
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk