Cancelling off thread compilation requests are not successful if the parse task has not finished
Categories
(Core :: JavaScript Engine, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox-esr68 | --- | unaffected |
firefox-esr78 | --- | unaffected |
firefox78 | --- | unaffected |
firefox79 | --- | disabled |
firefox80 | --- | disabled |
firefox81 | --- | disabled |
firefox82 | --- | fixed |
People
(Reporter: denispal, Assigned: denispal)
References
(Regression)
Details
(Keywords: regression)
Crash Data
Attachments
(3 files, 2 obsolete files)
In scriptloader, there is a race condition present between the cancellation of a request and the off thread compilation of a script. If the cancellation occurs before the parse task is finished then there is no token available to provide to JS::CancelOffThreadScript and the compiled script will leak.
Assignee | ||
Comment 1•4 years ago
|
||
Off thread compilations from the scriptloader can run into a potential race condition if the request is canceled before the parse is finished. This can lead to a leak since the off-thread compiled script is never properly cleaned up.
Assignee | ||
Comment 2•4 years ago
|
||
The attached patch fixes the leaks, but I'm seeing if there's another possible way by cancelling tasks asynchronously instead so we don't block the main thread waiting.
Comment 3•4 years ago
|
||
Set release status flags based on info from the regressing bug 1606652
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
Bug 1606652 introduced a regression where speculatively compiled JS scripts can leak if they are cancelled while the compilation is not finished. This occurs because the off thread token is not available until the callback occurs so when the cancel request is made, it simply returns because the token is null. The patch proposes a few changes:
- Add an optional parameter to the JS::Compile* and JS::Decode* functions that will return the parse task token right away.
- Wait for the off thread compilation to finish before cancelling any request. Most of the time, these will already be finished.
- Cancel off thread script compilations for any preload scripts when the load event fires to avoid leaks as they are likely not going to be executed.
Comment 5•4 years ago
|
||
Hi Denis, can you add a reviewer to your patch to see if it fixes bug 1265637?
Assignee | ||
Comment 6•4 years ago
|
||
(In reply to Andreea Pavel [:apavel] from comment #5)
Hi Denis, can you add a reviewer to your patch to see if it fixes bug 1265637?
Hi Andreea. Yes, it should fix the bug but after talking to smaug about it I am looking to try another approach first that does this slightly differently. Unfortunately it's not a trivial fix and only reproducible on try so it's been taking a bit of time. However, if the failures are becoming a problem I can turn the original feature off that caused this until this bug is resolved.
Comment 7•4 years ago
|
||
(In reply to Denis Palmeiro [:denispal] from comment #6)
(In reply to Andreea Pavel [:apavel] from comment #5)
Hi Denis, can you add a reviewer to your patch to see if it fixes bug 1265637?
Hi Andreea. Yes, it should fix the bug but after talking to smaug about it I am looking to try another approach first that does this slightly differently. Unfortunately it's not a trivial fix and only reproducible on try so it's been taking a bit of time. However, if the failures are becoming a problem I can turn the original feature off that caused this until this bug is resolved.
There are 325 total failures in the last 7 days on all trees, this a very high failure rate. If the fix takes longer than expected, then I would say turn the feature off if that's a safe approach.
Joel any insight on how to proceed here?
Comment 8•4 years ago
|
||
this is territory to backout, I assume getting the fix right and passing tests is not quick, so lets backout tomorrow if this is not up for review.
:denispal, do you need help?
Assignee | ||
Comment 9•4 years ago
|
||
(In reply to Joel Maher ( :jmaher ) (UTC-4) from comment #8)
this is territory to backout, I assume getting the fix right and passing tests is not quick, so lets backout tomorrow if this is not up for review.
:denispal, do you need help?
I think I should have a patch ready by EOD for review. Just doing some wider testing now. If the tests don't look good then I'll post a patch to flip dom.script_loader.external_scripts.speculative_omt_parse.enabled which should address these failures.
Assignee | ||
Comment 11•4 years ago
|
||
(In reply to Cosmin Sabou [:CosminS] from comment #10)
Denis, are there any updates here?
Yes, I did disable the offending feature in bug 1654357.
Comment 12•4 years ago
|
||
Thank you, then we should see a drop in failure rate in Bug 1265637 in the next few days.
Updated•4 years ago
|
Comment 13•4 years ago
|
||
It appears that the feature disabled in bug 1654357 was re-enabled by bug 1659483. Denis, do you have plans to work on this in the near future?
Assignee | ||
Comment 14•4 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #13)
It appears that the feature disabled in bug 1654357 was re-enabled by bug 1659483. Denis, do you have plans to work on this in the near future?
Yes, I am actively working on this now. The patch I have so far dramatically reduces the frequency in which the leaks appear, but it still shows up occasionally. Just trying to understand what I'm missing atm.
Comment 15•4 years ago
|
||
Thanks!
Updated•4 years ago
|
Assignee | ||
Comment 16•4 years ago
|
||
Assignee | ||
Comment 17•4 years ago
|
||
Depends on D89464
Assignee | ||
Comment 18•4 years ago
|
||
Depends on D89465
Comment 19•4 years ago
|
||
Comment 20•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c50c7898c277
https://hg.mozilla.org/mozilla-central/rev/294c4c7bb3e8
https://hg.mozilla.org/mozilla-central/rev/59cc6a4d3a55
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Description
•