Closed Bug 1173573 Opened 9 years ago Closed 9 years ago

Fix mysterious crash seen locally dealing with sessionstorage

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: mrbkap, Assigned: mrbkap)

Details

Attachments

(1 file, 1 obsolete file)

I have to admit that I'm not entirely sure that my patch for bug 1151840 isn't implicated here, but I saw a couple of crashes in a local debug build stemming from a child process's *session* storage manager being initialized before its *local* storage manager. This matters because DOMSessionStorageManager's constructor calls DOMStorageCache::StartDatabase, which calls DOMLocalStorageManager::Self in order to create a DOMStorageDBChild.

My STR were:
1. Start Firefox (opens a non-privatebrowsing window).
2. Open a privatebrowsing window.
3. Navigate to google.com.
4. Crash.

It appears that most of the time, we create the DOMLocalStorageManager early on due to nsGlobalWindow::PreloadLocalStorage (which is called as soon as we load the first non-chrome page in a process). However, it seems like there might be a race if we run a sessionstore collection (the offending code appears to be <http://mxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/SessionStorage.jsm?rev=85402fd3e3b4#142>) first.

I have a patch that fixes this.
Attached patch Possible patch (obsolete) — Splinter Review
Honza, I think you're the right person to review this. Let me know if that's not the case.

This simply fixes the bug by making sure we initialize both storage managers in the proper order when we need to.
Attachment #8620640 - Flags: review?(honzab.moz)
Assignee: nobody → mrbkap
Comment on attachment 8620640 [details] [diff] [review]
Possible patch

Review of attachment 8620640 [details] [diff] [review]:
-----------------------------------------------------------------

Very good catch!

::: dom/storage/DOMStorageManager.cpp
@@ +644,1 @@
>      DOMStorageCache::StartDatabase();

problem here is that if anyone called StartDatabase() sooner it will still be initialized w/o ls-m (if it were not instantiated till now)

hence, this do_GetService should move inside StartDatabase() or (preferred) there should be DOMLocalStorageManager* DOMLocalStorageManager::Ensure() that would make sure the manager service is up (and simply return sSelf then).  Ensure() then will be use to init the database instead of Self() at [1].

[1] http://hg.mozilla.org/mozilla-central/annotate/be81b8d6fae9/dom/storage/DOMStorageCache.cpp#l775
Attachment #8620640 - Flags: review?(honzab.moz) → review-
Attached patch Patch v2Splinter Review
Attachment #8620640 - Attachment is obsolete: true
Attachment #8625495 - Flags: review?(honzab.moz)
Comment on attachment 8625495 [details] [diff] [review]
Patch v2

Review of attachment 8625495 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks!
Attachment #8625495 - Flags: review?(honzab.moz) → review+
https://treeherder.mozilla.org/#/jobs?repo=try&revision=aa7480b06109 is still running, but this really shouldn't break anything.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c76f4193401b
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: