[PATCH] Fix ThreadWeaver JobCollection deletion race

Robert Knight robertknight at gmail.com
Wed Mar 26 15:06:51 UTC 2008


Hello,

The attached patch fixes a couple of problems with deleting
JobCollection / JobSequence jobs in threadweaver which were causing
sporadic failures in threadweaver's DeleteTest and in KDevelop after a
parsing job completed.

Each JobCollection starts a number of JobCollectionJobRunner sub-jobs
which are owned by the JobCollection.  The last JobCollectionJobRunner
and collection Job finished after the JobCollection's done() signal had
been emitted.  If the JobCollection was after its done() signal had been
emitted and before its child jobs had finished, it would also delete its
JobCollectionJobRunners and crash. 

ThreadWeaver's API documentation does not make it clear when it is safe
to delete a Job.  The ThreadWeaver tests assume that when the
ThreadWeaver instance emits a jobDone(Job*) signal then it is safe to
delete that job.  KDevelop currently listens for a JobSequence's
done(Job*) signal and then starts a timer to delete the Job 100ms or so
in the future.  On my system that was not long enough every 20 runs or
so a Job would be deleted while ThreadWeaver was still using it.

I suggest making it explicit that a Job can be safely deleted (with
respect to ThreadWeaver itself) as soon as it emits its done(Job*)
signal.  With the attached patch ThreadWeaver conforms to these
semantics.

Any comments?  Okay to commit?

Regards,
Robert.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: threadweaver_fix_jobcollection_deletion_race.patch
Type: text/x-patch
Size: 6865 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20080326/298a5ae3/attachment.patch>


More information about the KDevelop-devel mailing list