aboutsummaryrefslogtreecommitdiff
path: root/www/waterfox/files/patch-bug1415598
blob: 6fd819610ca93a0614965b69506a8f2e979d2def (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
commit 63db080ae5cb
Author: Marco Bonardo <mbonardo@mozilla.com>
Date:   Thu Dec 7 15:28:41 2017 +0100

    Bug 1415598. r=gijs, a=jcristau
    
    --HG--
    extra : source : 94f1fb1043a81e619d7b73d48a86d66d1cf4eebc
---
 toolkit/components/places/History.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git toolkit/components/places/History.cpp toolkit/components/places/History.cpp
index 94755d3bdde5..b3618c065601 100644
--- toolkit/components/places/History.cpp
+++ toolkit/components/places/History.cpp
@@ -1955,6 +1955,7 @@ History::InitMemoryReporter()
 NS_IMETHODIMP
 History::NotifyVisited(nsIURI* aURI)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_ARG(aURI);
 
   nsAutoScriptBlocker scriptBlocker;
@@ -2565,6 +2566,7 @@ NS_IMETHODIMP
 History::RegisterVisitedCallback(nsIURI* aURI,
                                  Link* aLink)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   NS_ASSERTION(aURI, "Must pass a non-null URI!");
   if (XRE_IsContentProcess()) {
     NS_PRECONDITION(aLink, "Must pass a non-null Link!");
@@ -2594,7 +2596,16 @@ History::RegisterVisitedCallback(nsIURI* aURI,
     if (NS_FAILED(rv) || !aLink) {
       // Remove our array from the hashtable so we don't keep it around.
       MOZ_ASSERT(key == mObservers.GetEntry(aURI), "The URIs hash mutated!");
-      mObservers.RemoveEntry(key);
+      // In some case calling RemoveEntry on the key obtained by PutEntry
+      // crashes for currently unknown reasons.  Our suspect is that something
+      // between PutEntry and this call causes a nested loop that either removes
+      // the entry or reallocs the hash.
+      // TODO (Bug 1412647): we must figure the root cause for these issues and
+      // remove this stop-gap crash fix.
+      key = mObservers.GetEntry(aURI);
+      if (key) {
+        mObservers.RemoveEntry(key);
+      }
       return rv;
     }
   }
@@ -2626,6 +2637,7 @@ NS_IMETHODIMP
 History::UnregisterVisitedCallback(nsIURI* aURI,
                                    Link* aLink)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   // TODO: aURI is sometimes null - see bug 548685
   NS_ASSERTION(aURI, "Must pass a non-null URI!");
   NS_ASSERTION(aLink, "Must pass a non-null Link object!");