Closed
Bug 325521
Opened 20 years ago
Closed 19 years ago
JS_YieldRequest() allows the garbage collector to race
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.8.1beta1
People
(Reporter: daumling, Assigned: daumling)
Details
(Keywords: fixed1.8.1)
Attachments
(1 file)
918 bytes,
patch
|
brendan
:
review+
mtschrep
:
approval1.8.1+
|
Details | Diff | Splinter Review |
JS_YieldRequest() is IMHO a quick replacement for a JS_SuspendRequest/JS_ResumeRequest combo. If used, a garbage collector on a separate thread races. It appears that the function does not wait for any garbage collector to succeed.
I do not have the latest Trucnk code installed, so please forgive me if I submit my proposed fix here. This fix appears to work well.
JS_PUBLIC_API(void)
JS_YieldRequest(JSContext *cx)
{
JSRuntime *rt;
JS_ASSERT(cx->thread);
CHECK_REQUEST(cx);
rt = cx->runtime;
JS_LOCK_GC(rt);
JS_ASSERT(rt->requestCount > 0);
rt->requestCount--;
if (rt->requestCount == 0)
JS_NOTIFY_REQUEST_DONE(rt);
JS_UNLOCK_GC(rt);
/* XXXbe give the GC or another request calling it a chance to run here?
Assumes FIFO scheduling */
JS_LOCK_GC(rt);
/* BEGIN FIX */
if (rt->gcThread != cx->thread) {
while (rt->gcLevel > 0)
JS_AWAIT_GC_DONE(rt);
}
/* END FIX */
rt->requestCount++;
JS_UNLOCK_GC(rt);
}
Brendan, please review if this fix is correct.
Comment 1•20 years ago
|
||
shaver, what do you think? Looks like the right fix to me.
/be
Comment 2•20 years ago
|
||
Yeah, it does.
Assignee | ||
Comment 3•20 years ago
|
||
Since you agree that this is the fix, I'll take the bug.
Assignee: general → daumling
Assignee | ||
Updated•20 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•20 years ago
|
||
Attachment #210984 -
Flags: review?(brendan)
Comment 5•20 years ago
|
||
Comment on attachment 210984 [details] [diff] [review]
Patch as desrbied in bug.
Checking in, and I took the opportunity to trim trailing spaces from unrelated lines in this file.
/be
Attachment #210984 -
Flags: review?(brendan) → review+
Updated•19 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Updated•19 years ago
|
Flags: testcase-
Updated•19 years ago
|
Flags: blocking1.8.1?
There's a blocking1.8.1? nomination on this bug. Should it be landed on the 1.8 branch for 1.8.1?
Updated•19 years ago
|
Attachment #210984 -
Flags: approval1.8.1+
Updated•19 years ago
|
Flags: blocking1.8.1? → blocking1.8.1+
Updated•19 years ago
|
Whiteboard: [checkin needed]
Comment 7•19 years ago
|
||
Is this part of the JS 1.7 landing? If not, can we get it checked in to the 1.8.1 branch?
Target Milestone: --- → mozilla1.8.1beta1
Updated•19 years ago
|
Keywords: fixed1.8.1
You need to log in
before you can comment on or make changes to this bug.
Description
•