Closed Bug 84489 Opened 24 years ago Closed 24 years ago

threadpool assumes runnables are threadsafe

Categories

(Core :: XPCOM, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.2

People

(Reporter: dougt, Assigned: dougt)

References

Details

Attachments

(2 files)

The current threadpool makes assumptions that the nsIRunnables are threadsafe. This causes some nasty problems such as 71397. The threadpool should enforce a policy which allows non-threadsafe implementations of nsIRunnable to safely exists. Making sure that the same request is not running on more than one thread at the same time will enforce such a policy.
The last patch adds a testcase to TestThreads which fingers the problem which has been reported as a top crasher with the stack ending in nsFileIO crashers. (see 71397). The test basically has one request run multiple times. The request's Run() is not threadsafe. So, setting/getting the member var will be overwritten by other threads running the same request. CC'ing thread hackers.
Blocks: 71397
Proposed Changes: Added new variable for keeping track of the currently running requests: mRunningRequests. Renamed some variables name so that we don't confuse pending requests with running requests. Added new function to the nsThreadPool so that I could tell when the request is finished: |RequestDone|. I am a little unhappy about having to add this function, but I don't see any other way that I can tell the pool from the runnable that the runnable is done. This function simply removes the request from the mRunningRequests list. The biggest change is that the first thing we do inside of nsThreadPool::GetRequest is to check to see that the request that we pull out of mPendingRequests is not already running. If it is, we try the next one in the list and so on. If we find that there are not request which can be run, we do what we have been doing - check to see if the thread should go away otherwise wait.
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Priority: -- → P1
Target Milestone: --- → mozilla0.9.2
looks good to me! sr=darin
great. dan, can you r= this? Brendan, can you give me a fat a=?
(Me writing down what I believe I've discovered about this bug) Doug explains that requests are being taken off the pending list, set running, and then returned to the pending list when their action is cancelled. For a moment the pending list contains bogus entries; this patch guards against that. OK. r=danm
I am concerned about what you think I fixed. :-) The basic idea is that if a runnable R is already running on any of the threadpool's worker thread, it doesn't run the same runnable R, dispatched as a new request, until the running runnable is finished. really a rad run ran rhyme.
Blocks: 83989
a=clayton
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: