Crash in [@ mozilla::dom::ScriptLoadContext::~ScriptLoadContext] with MOZ_DIAGNOSTIC_ASSERT(!mCompileOrDecodeTask)
Categories
(Core :: Performance: Navigation, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr115 | --- | unaffected |
| firefox-esr140 | --- | unaffected |
| firefox151 | --- | unaffected |
| firefox152 | --- | unaffected |
| firefox153 | blocking | fixed |
People
(Reporter: RyanVM, Assigned: denispal)
References
(Regression)
Details
(Keywords: crash, regression, topcrash)
Crash Data
Attachments
(1 external file)
Crash report: https://crash-stats.mozilla.org/report/index/837df61b-0c39-4f20-acaf-bef800260601
MOZ_CRASH Reason:
MOZ_DIAGNOSTIC_ASSERT(!mCompileOrDecodeTask)
Top 10 frames:
0 xul.dll mozilla::dom::ScriptLoadContext::~ScriptLoadContext() dom/script/ScriptLoadContext.cpp:73
1 xul.dll mozilla::dom::ScriptLoadContext::~ScriptLoadContext() dom/script/ScriptLoadContext.cpp:69
2 xul.dll SnowWhiteKiller::MaybeKillObject(SnowWhiteKiller::SnowWhiteObject&) xpcom/base/nsCycleCollector.cpp:2677
2 xul.dll SnowWhiteKiller::~SnowWhiteKiller() xpcom/base/nsCycleCollector.cpp:2664
3 xul.dll nsCycleCollector::FreeSnowWhite(bool) xpcom/base/nsCycleCollector.cpp:2855
4 xul.dll nsCycleCollector::CleanupAfterCollection() xpcom/base/nsCycleCollector.cpp:3601
4 xul.dll nsCycleCollector::Collect(mozilla::CCReason, ccIsManual, JS::SliceBudget&, ns... xpcom/base/nsCycleCollector.cpp:3771
5 xul.dll nsCycleCollector_collectSlice(JS::SliceBudget&, mozilla::CCReason, bool) xpcom/base/nsCycleCollector.cpp:4317
6 xul.dll nsJSContext::RunCycleCollectorSlice(mozilla::CCReason, mozilla::TimeStamp) dom/base/nsJSEnvironment.cpp:1149
6 xul.dll mozilla::CCGCScheduler::CCRunnerFired(mozilla::TimeStamp) dom/base/nsJSEnvironment.cpp:1326
| Reporter | ||
Comment 1•5 months ago
|
||
Potential root-cause analysis (Opus 4.8).
The assertion that fires is in ~ScriptLoadContext (dom/script/ScriptLoadContext.cpp:73):
// Off-thread parsing must have completed or cancelled by this point.
MOZ_DIAGNOSTIC_ASSERT(!mCompileOrDecodeTask);
It's hit from the cycle collector (SnowWhiteKiller), i.e. the ScriptLoadRequest is torn down via the script-element <-> request cycle while it still owns a live off-thread compile/decode task.
mCompileOrDecodeTask is only ever cleared in two places:
ScriptLoadContext::MaybeCancelOffThreadScript()- the abandon path (Cancel()then= nullptr).ScriptLoadContext::StealOffThreadResult()- the execution path (.forget()).
So for the assert to fire, a request had to finish off-thread compilation but then be released without going through either execution or cancellation.
That is exactly the lifecycle the regressing change (bug 2037599) altered. It added this branch to ScriptLoader::ProcessOffThreadRequest:
} else if (aRequest->GetScriptLoadContext()->mInAsyncList) {
// This async request may already be in mLoadingAsyncRequests while its
// off-thread compilation finishes. Now that it is ready, move it to
// mLoadedAsyncRequests so ProcessPendingRequests can execute it.
MaybeMoveToLoadedList(aRequest);
}
Before the patch, a speculatively-compiled async/link-preload script whose element appeared mid-compile was left stuck in mLoadingAsyncRequests (the leak the bug describes). That was harmless with respect to this assert: the request stayed referenced in a ScriptLoader list, and at teardown mLoadingAsyncRequests.CancelRequestsAndClear() runs MaybeCancelOffThreadScript(), clearing the task.
After the patch, the request is Steal-ed out of mLoadingAsyncRequests and appended to mLoadedAsyncRequests, putting it on the execution path. It now appears reachable for one of these requests to be disposed of via cycle collection (the element/request cycle) rather than the orderly execute-or-cancel paths, so it reaches ~ScriptLoadContext with mCompileOrDecodeTask still set.
The fix likely needs to guarantee the off-thread task is stolen or cancelled on every path a moved request can be torn down, not just the normal ProcessPendingRequests execution path.
Comment 2•5 months ago
|
||
The bug is linked to a topcrash signature, which matches the following criterion:
- Top 10 desktop browser crashes on nightly
For more information, please visit BugBot documentation.
Updated•5 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
| Assignee | ||
Comment 4•5 months ago
|
||
After we enabled speculative compilation for link preload scripts, a request can now finish compiling off-thread and then get dropped by CC before we execute it and steal the result. In
that case ScriptLoadContext still has mCompileOrDecodeTask set and trips the destructor assert. The fix is to clear the task when ScriptLoadContext is unlinked or destroyed. Previously,
OMT compilation was normally tied to requests for script elements that were already on an execution path, so they would go through either the steal path or the teardown path.
Updated•5 months ago
|
Comment 6•5 months ago
|
||
| bugherder | ||
Updated•5 months ago
|
Description
•