Bug 1282185 (part 2) - Fix an assertion failure in DMD. r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 13 Jul 2016 19:32:27 +1000
changeset 304903 2f8d5f889b47589b79a8ad95456f863c1b83cfb4
parent 304902 d8e2cf1f7079f756f65654dca128245ddc3d4a6f
child 304904 8e3acbc708b62db2a091a587c40953e9ed41c786
push id79454
push usernnethercote@mozilla.com
push dateThu, 14 Jul 2016 03:17:03 +0000
treeherdermozilla-inbound@2f8d5f889b47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1282185
milestone50.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 1282185 (part 2) - Fix an assertion failure in DMD. r=erahm.
memory/replace/dmd/DMD.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -1824,16 +1824,25 @@ WriteBlockContents(JSONWriter& aWriter, 
     }
   }
   aWriter.EndArray();
 }
 
 static void
 AnalyzeImpl(UniquePtr<JSONWriteFunc> aWriter)
 {
+  // Some blocks may have been allocated while creating |aWriter|. Those blocks
+  // will be freed at the end of this function when |write| is destroyed. The
+  // allocations will have occurred while intercepts were not blocked, so the
+  // frees better be as well, otherwise we'll get assertion failures.
+  // Therefore, this declaration must precede the AutoBlockIntercepts
+  // declaration, to ensure that |write| is destroyed *after* intercepts are
+  // unblocked.
+  JSONWriter writer(Move(aWriter));
+
   AutoBlockIntercepts block(Thread::Fetch());
   AutoLockState lock;
 
   // Allocate this on the heap instead of the stack because it's fairly large.
   auto locService = InfallibleAllocPolicy::new_<CodeAddressService>();
 
   StackTraceSet usedStackTraces;
   MOZ_ALWAYS_TRUE(usedStackTraces.init(512));
@@ -1841,17 +1850,16 @@ AnalyzeImpl(UniquePtr<JSONWriteFunc> aWr
   PointerSet usedPcs;
   MOZ_ALWAYS_TRUE(usedPcs.init(512));
 
   size_t iscSize;
 
   static int analysisCount = 1;
   StatusMsg("Dump %d {\n", analysisCount++);
 
-  JSONWriter writer(Move(aWriter));
   writer.Start();
   {
     writer.IntProperty("version", kOutputVersionNumber);
 
     writer.StartObjectProperty("invocation");
     {
       const char* var = gOptions->DMDEnvVar();
       if (var) {