Closed Bug 1975674 Opened 11 months ago Closed 11 months ago

Firefox crashes in nsIFile::Contains on Windows when path is null while writing extensions.json

Categories

(Toolkit :: Add-ons Manager, defect, P3)

defect

Tracking

()

RESOLVED FIXED
142 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox-esr140 --- fixed
firefox140 --- wontfix
firefox141 --- wontfix
firefox142 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

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

Crash Data

Attachments

(2 files)

I investigated a report of a crash in bug 1975255, where the browser allegedly crashed when a profile directory is reused on different operating systems (Windows & Linux), bp-3abf727b-0791-437c-ad6a-1f15e0250610.

I identified a likely root cause for the crash:

We should fall back more gracefully than crashing the browser entirely. This problem is also likely a root cause of bug 1580252, which was closed because nobody could figure out what was happening.

I pinpointed the issue to the relativePath getter mentioned above, because there are very few callers of nsIFile::Contains in the code base, and out of all callers that I audited, only the logic in XPIProvider can pass null potentially. Furthermore, although most stack traces provide little information (with stack traces similar to bug 1580252), some crash reports also include mozilla::dom::IOUtils::WriteJSON on the stack (e.g. bp-6a6ff464-0302-4663-b1e4-22a6b0250613), which is another pointer towards the relativePath getter, because that getter is invoked from toJSON, triggered via IOUtils.writeJSON() call in XPIDatabase (this writes the extensions.json file).

This is a Windows-only crash which I can reproduce by running the following snippet in the global Browser Console: FileUtils.File("C:\\").contains(null)

Results in the following crash: bp-623b9791-4add-4de9-93b6-472c30250703

I'll fix this by adding a nullptr check to https://searchfox.org/mozilla-central/rev/02545fb16ddbc8dae7788c6f52be2c1504b50345/xpcom/io/nsLocalFileWin.cpp#3139

similar to what we already have on other platforms: https://searchfox.org/mozilla-central/rev/02545fb16ddbc8dae7788c6f52be2c1504b50345/xpcom/io/nsLocalFileUnix.cpp#2117

Assignee: nobody → rob
Status: NEW → ASSIGNED
  • add basic unit tests, run with: ./mach gtest TestFile.*
Severity: -- → S3
Priority: -- → P3
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch

The patch landed in nightly and beta is affected.
:robwu, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(rob)

Although the patch has minimal risk, the volume of crashes is low, so it doesn't have to be uplifted to Beta. 66% of the crashes are on ESR (ESR128, ESR115, and with low volume ESR140).

Because of the low risk to the patch (changing the hard crash to an error so that Windows behaves like other platforms) coupled with the high severity if encountered (main process crash), I'm inclined to uplift this to all ESR branches.

Flags: needinfo?(rob)

The above stats are based on crashes in the past 6 months. If I filter to the last month, 115 does not appear.

ESR128 is almost EOL.

So I'm only going to uplift to ESR140.

  • add basic unit tests, run with: ./mach gtest TestFile.*

Original Revision: https://phabricator.services.mozilla.com/D256255

Attachment #9499470 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined: Startup crash in rare circumstances on Windows. Affects all products including Firefox and Thunderbird.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: no
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: QA not needed, but if desired, STR: https://bugzilla.mozilla.org/show_bug.cgi?id=1975674#c1
  • Risk associated with taking this patch: Low
  • Explanation of risk level: Changes crash to raising an error, consistent with all non-Windows platforms
  • String changes made/needed: None
  • Is Android affected?: no
Attachment #9499470 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
QA Whiteboard: [qa-triage-done-c142/b141]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: