Closed Bug 2006233 Opened 1 month ago Closed 24 days ago

browser.declarativeNetRequest.* calls throw sometimes, depending on whether a second extension is installed

Categories

(WebExtensions :: Request Handling, defect, P1)

Firefox 147
defect

Tracking

(firefox-esr115 wontfix, firefox-esr140 fixed, firefox146 wontfix, firefox147 wontfix, firefox148 fixed)

RESOLVED FIXED
148 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr140 --- fixed
firefox146 --- wontfix
firefox147 --- wontfix
firefox148 --- fixed

People

(Reporter: bugzilla, Assigned: robwu)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [addons-jira])

Attachments

(2 files, 1 obsolete file)

Steps to reproduce:

Minimal repro:

  1. In Developer Edition 147.0b4,
  2. Disable xpinstall.signatures.required in about:config
  3. Download main-extension.zip and privacypass-extension.zip from https://github.com/jacobwinters/firefox-declarativeNetRequest-repro
  4. Install them as extensions
  5. Visit https://kagi.com
  6. Restart the browser
  7. Visit https://kagi.com again
  8. In about:debugging, inspect the Kagi Search for Firefox extension (main-extension.zip)
  9. In the extension's console, run browser.declarativeNetRequest.getDynamicRules()
  10. "Uncaught (in promise) Error: An unexpected error occurred"
  11. Most other functions on browser.declarativeNetRequest do that too

User-facing version from which it was derived: installing both the Kagi Search for Firefox and Kagi Privacy Pass extensions at the same time breaks the first one's auth functionality, which is implemented through declarativeNetRequest. When the full user-facing problem is happening, steps 8-11 apply unchanged.

Actual results:

Exception thrown from declarativeNetRequest.getDynamicRules.

Browser toolbox console shows the following:

Unexpected non-empty DNRStore data. DNR startupCache data load aborted. 24 ExtensionDNRStore.sys.mjs:1204:11
    #promiseStartupCacheLoaded resource://gre/modules/ExtensionDNRStore.sys.mjs:1204
    #readStoreDataFromStartupCache resource://gre/modules/ExtensionDNRStore.sys.mjs:1366
    _readData resource://gre/modules/ExtensionDNRStore.sys.mjs:1292
    #readData resource://gre/modules/ExtensionDNRStore.sys.mjs:1284
    #getDataPromise resource://gre/modules/ExtensionDNRStore.sys.mjs:841
    #initExtension resource://gre/modules/ExtensionDNRStore.sys.mjs:1155
    InterpretGeneratorResume self-hosted:1312
    AsyncFunctionNext self-hosted:780

I'm guessing that there's some sort of concurrency bug around that object's _data field that's triggered in the presence of multiple extensions. Not sure how else to explain the way the bug depends on the second extension, which in the minimal repro case is just a manifest file.

Expected results:

I don't think that declarativeNetRequest calls should fail under these conditions.

The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Product: Firefox → WebExtensions
Component: Untriaged → Request Handling

I'll investigate.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(rob)

What happens here is as follows:

  1. We load an extension that does not have any DNR rules. That causes the extension's StartupCache to be populated with the knowledge that the extension does not have any rules.
  2. We load another extension with rules (whether static or dynamic).
  3. After restarting Firefox, we see the first extension without rules, and as an optimization skip the more expensive full initialization, and partially initialize _data (link to #initExtension implementation).
  4. However, when the second extension starts up, as yet another optimization we attempt to read the parsed rules (from another startup cache file) (entry point). This commences the full initialization from cached data, but the logic there assumes that we have not initialized any data yet. Because we did initialize (empty) data for an extension, that check fails and we raise an error (link to #promiseStartupCacheLoaded implementation).

We should accept this scenario and not raise an error in this case.

Assignee: nobody → rob
Status: NEW → ASSIGNED
Flags: needinfo?(rob)
Keywords: regression
Regressed by: 1921353
Whiteboard: [addons-jira]

Set release status flags based on info from the regressing bug 1921353

Severity: -- → S3
Priority: -- → P1
Duplicate of this bug: 1995192
Status: ASSIGNED → RESOLVED
Closed: 24 days ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Attachment #9537165 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined: The declarativeNetRequest extension API fails to initialize after a browser restart, when two or more extensions use this API. The exact conditions are described in https://bugzilla.mozilla.org/show_bug.cgi?id=2006233#c3
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: Not needed, but provided in the bug report.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Fix in DNR implementation covered by automated tests.
  • String changes made/needed: None
  • Is Android affected?: yes
Attachment #9537168 - Flags: approval-mozilla-esr115?

firefox-esr115 Uplift Approval Request

  • User impact if declined: The declarativeNetRequest extension API fails to initialize after a browser restart, when two or more extensions use this API. The exact conditions are described in https://bugzilla.mozilla.org/show_bug.cgi?id=2006233#c3
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: Not needed, but provided in the bug report.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Fix in DNR implementation covered by automated tests.
  • String changes made/needed: None
  • Is Android affected?: yes
Attachment #9537165 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9537168 - Attachment is obsolete: true
Attachment #9537168 - Flags: approval-mozilla-esr115?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: