Open Bug 1503945 Opened 6 years ago Updated 2 years ago

Potential memory leak in devtools_page and devtools.panels around extension startup and shutdown

Categories

(WebExtensions :: Developer Tools, defect, P3)

64 Branch
defect

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

Details

ext-devtools-panels.js and ext-devtools.js both create <browser> elements, and initialize them asynchronously. The implementations do not account for the possibility of extension shutdown, and consequently there may be unexpected memory leaks or other errors when the initialization continues after the extension has shut down (e.g. when an add-on reloads/updates). Details for ext-devtools-panels.js 1. Browser initialization: https://searchfox.org/mozilla-central/rev/eac6295c397133b7346822ad31867197e30d7e94/browser/components/extensions/parent/ext-devtools-panels.js#47-78 2. getBrowser implementation: https://searchfox.org/mozilla-central/rev/39cb1e96cf97713c444c5a0404d4f84627aee85d/browser/base/content/webext-panels.js#22-80 3. Shutdown handler: https://searchfox.org/mozilla-central/rev/eac6295c397133b7346822ad31867197e30d7e94/browser/components/extensions/parent/ext-devtools-panels.js#81-92 Currently, the clean-up at (3) only works if it runs after (1) and (2). If step 3 runs earlier (due to the extension shutdown), then step (1) may leak the <browser> element and an event listener. Details for ext-devtools.js 1. Browser initialization: https://searchfox.org/mozilla-central/rev/39cb1e96cf97713c444c5a0404d4f84627aee85d/browser/components/extensions/parent/ext-devtools.js#145-175 2. createBrowserElement implementation: https://searchfox.org/mozilla-central/rev/eac6295c397133b7346822ad31867197e30d7e94/toolkit/components/extensions/ExtensionParent.jsm#1135-1164 3. Shutdown handler: https://searchfox.org/mozilla-central/rev/39cb1e96cf97713c444c5a0404d4f84627aee85d/browser/components/extensions/parent/ext-devtools.js#179-199 The logic is similar to the previous case; If (3) runs too early, then step (2) may leak the browser element (and/or event listeners/observers), and (1) can leak an event listener and/or load the page of an extension that was supposedly shut down. The createBrowserElement that ext-devtools.js relies upon is also used by ext-backgroundPage.js, and also a potential cause for bug 1501375.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.