wikipedia runner crasher, was: Re: runners: same .so, different configs?

Aaron J. Seigo aseigo at kde.org
Mon Nov 2 21:34:02 CET 2009


On October 31, 2009, Sebastian Kügler wrote:
> I've tried different variants, a QMutex to lock access to the shared class
>  for example, but nothing would really help. Can anyone tell me how I can
>  fix this in the right way?

a few things jump out at me:

* m_mediaWiki is being shared by all threads. consider two threads (T0 and T1) 
running like this (in chronological order):

T0::match -> wait 1s on line 84
T1::match -> wait 1s on line 84
T0::match -> assign m_mediaWiki and starts query
T1::match -> assigns m_mediaWiki (!)
T0::match -> query is done, delete m_mediaWiki object (!!)
T1::mediaWikiFinished -> m_mediaWiki is now null .. crash.

my suggestion would be to put the MediaWiki object on the stack local to 
match() and not bother having to delete it at all. it will also help solve 
another potential problem:

* since there is only one m_context member, whatever matches get returned, 
even if from an older query, will be added to the last m_context object 
returned. which means it is possible that matches will get added to a context 
which no longer actually matches. 

if the Context * is passed into MediaWiki, then in MediaWiki::finished( 
QNetworkReply *reply )  it can check context->isValid() and if it is add the 
matches itself. this prevents having to cache m_context in the runner. then 
the finished(bool) signal simply serves to exit the event loop in match()

* a check for context.isValid() should be added after the waiting code on 
lines 83-85 to prevent queries that no longer are valid from being searched 
for. the same is true for mediaWikiFinished.

btw, why aren't you using KIO directly in MediaWiki?

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20091102/97bcb781/attachment.sig 


More information about the Plasma-devel mailing list