CacheEntry pending callbacks form prevent-release cycle at shutdown, leaking nsGlobalWindowInner
Categories
(Core :: Networking: Cache, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox151 | --- | fixed |
People
(Reporter: florian, Assigned: florian)
References
Details
(Whiteboard: [necko-triaged])
Attachments
(1 external file)
CacheEntry stores pending callbacks in its mCallbacks array. Each Callback holds a RefPtr<CacheEntry> mEntry back to the owning entry, forming a prevent-release cycle:
CacheEntry → mCallbacks[i] → Callback.mEntry → CacheEntry
Normally this cycle is broken when the callback fires and is removed from the array. But when an async disk cache read (OPEN_SECRETLY) doesn't complete before process shutdown, the callback is never invoked.
CacheStorageService::Shutdown() clears the global entry tables (under NS_FREE_PERMANENT_DATA), which drops the table's reference to the CacheEntry — but the CacheEntry ↔ Callback cycle keeps both alive. The leaked Callback holds an nsICacheEntryOpenCallback whose JS closure chains through devtools module scopes to a chrome window's global, preventing the nsGlobalWindowInner from being cycle-collected.
Reproduces as a perma-fail on debug builds when running devtools mochitests without the memory-pressure notification (bug 2030904 removes it from the shutdown leak check). For example:
./mach test devtools/client/framework/test/browser_toolbox_options_disable_cache-02.js --headless
The failure message on treeherder is unfortunately not very actionable: TEST-UNEXPECTED-FAIL | leakcheck large nsGlobalWindowInner | devtools/client/framework/test/browser.toml
The fix: clear pending callbacks on all entries during CacheStorageService::Shutdown() before dropping the entry tables, breaking the prevent-release cycle.
| Assignee | ||
Comment 1•7 months ago
|
||
Updated•7 months ago
|
Updated•7 months ago
|
Comment 2•7 months ago
|
||
I was ready to put up a patch for it, but you beat me :-)
Comment 4•7 months ago
|
||
| bugherder | ||
Updated•7 months ago
|
Description
•