[PATCH] Fix ThreadWeaver JobCollection deletion race

Robert Knight rwk105 at ecs.soton.ac.uk
Wed Mar 26 14:56:27 GMT 2008


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

Any comments?  Okay to commit?

-------------- 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/kde-core-devel/attachments/20080326/fcd0a023/attachment.bin>

More information about the kde-core-devel mailing list