Bug 1436156 - CHECK() in Chromium IPC code should be fatal when not fuzzing. r=froydnj
authorJed Davis <jld@mozilla.com>
Tue, 10 Apr 2018 12:36:46 -0600
changeset 413099 8b413e24051fcc4992b9f66382b93832e2e88074
parent 413098 15332e1d2eda348b7081c8df9cd47dcca79e4401
child 413100 8056a366eaba1882d827ddf7604d94f1d2d8442e
push id33833
push useraiakab@mozilla.com
push dateFri, 13 Apr 2018 09:41:15 +0000
treeherdermozilla-central@260e4c83c8a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1436156, 1445121
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436156 - CHECK() in Chromium IPC code should be fatal when not fuzzing. r=froydnj Includes a workaround for bug 1445121. MozReview-Commit-ID: 4iQqzzECCK8
ipc/chromium/src/base/logging.h
ipc/glue/ProtocolUtils.cpp
--- a/ipc/chromium/src/base/logging.h
+++ b/ipc/chromium/src/base/logging.h
@@ -114,17 +114,21 @@ const mozilla::EmptyLog& operator <<(con
 #undef LOG_ASSERT
 #define LOG_ASSERT(cond) CHECK(0)
 #define DLOG_ASSERT(cond) DCHECK(0)
 
 #define NOTREACHED() CHROMIUM_LOG(ERROR)
 #define NOTIMPLEMENTED() CHROMIUM_LOG(ERROR)
 
 #undef CHECK
+#ifdef FUZZING
 #define CHECK(condition) LOG_IF(WARNING, condition)
+#else
+#define CHECK(condition) LOG_IF(FATAL, condition)
+#endif
 
 #define DCHECK_EQ(v1, v2) DCHECK((v1) == (v2))
 #define DCHECK_NE(v1, v2) DCHECK((v1) != (v2))
 #define DCHECK_LE(v1, v2) DCHECK((v1) <= (v2))
 #define DCHECK_LT(v1, v2) DCHECK((v1) < (v2))
 #define DCHECK_GE(v1, v2) DCHECK((v1) >= (v2))
 #define DCHECK_GT(v1, v2) DCHECK((v1) > (v2))
 
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -927,17 +927,27 @@ IToplevelProtocol::SetEventTargetForActo
   MOZ_RELEASE_ASSERT(aActor->Id() == kNullActorId || aActor->Id() == kFreedActorId);
 
   // Register the actor early. When it's registered again, it will keep the same
   // ID.
   int32_t id = Register(aActor);
   aActor->SetId(id);
 
   MutexAutoLock lock(mEventTargetMutex);
-  mEventTargetMap.AddWithID(aEventTarget, id);
+  // FIXME bug 1445121 - sometimes the id is already mapped.
+  // (IDMap debug-asserts that the existing state is as expected.)
+  bool replace = false;
+#ifdef DEBUG
+  replace = mEventTargetMap.Lookup(id) != nullptr;
+#endif
+  if (replace) {
+    mEventTargetMap.ReplaceWithID(aEventTarget, id);
+  } else {
+    mEventTargetMap.AddWithID(aEventTarget, id);
+  }
 }
 
 void
 IToplevelProtocol::ReplaceEventTargetForActorInternal(
   IProtocol* aActor,
   nsIEventTarget* aEventTarget)
 {
   // The EventTarget of a ToplevelProtocol shall never be set.