Bug 1500805 Part 7 - Avoid crashing after a middleman call returns a null value, r=mccr8.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 21 Oct 2018 15:09:20 -0600
changeset 491292 31b1aec1f478396b13afd5adb7bae220ca1b5d44
parent 491291 0b8359215f5b0e02a2ee693615a34c218662e7df
child 491293 c8ca4a20631561e4a7a6cf68be07ec2eef2e7bd0
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmccr8
bugs1500805
milestone65.0a1
Bug 1500805 Part 7 - Avoid crashing after a middleman call returns a null value, r=mccr8.
toolkit/recordreplay/MiddlemanCall.cpp
toolkit/recordreplay/ProcessRedirect.cpp
--- a/toolkit/recordreplay/MiddlemanCall.cpp
+++ b/toolkit/recordreplay/MiddlemanCall.cpp
@@ -158,17 +158,17 @@ ProcessMiddlemanCall(const char* aInputD
   BufferStream inputStream(aInputData, aInputSize);
   BufferStream outputStream(aOutputData);
 
   while (!inputStream.IsEmpty()) {
     MiddlemanCall* call = new MiddlemanCall();
     call->DecodeInput(inputStream);
 
     const Redirection& redirection = gRedirections[call->mCallId];
-    MOZ_RELEASE_ASSERT(gRedirections[call->mCallId].mMiddlemanCall);
+    MOZ_RELEASE_ASSERT(redirection.mMiddlemanCall);
 
     CallArguments arguments;
     call->mArguments.CopyTo(&arguments);
 
     {
       MiddlemanCallContext cx(call, &arguments, MiddlemanCallPhase::MiddlemanInput);
       redirection.mMiddlemanCall(cx);
     }
@@ -318,16 +318,19 @@ MangleSystemValue(const void* aValue, bo
 {
   return (const void*) ((size_t)aValue | (1ULL << (aFromRecording ? 63 : 62)));
 }
 
 void
 Middleman_SystemOutput(MiddlemanCallContext& aCx, const void** aOutput, bool aUpdating)
 {
   if (!*aOutput) {
+    if (aCx.mPhase == MiddlemanCallPhase::MiddlemanOutput) {
+      aCx.mCall->SetMiddlemanValue(*aOutput);
+    }
     return;
   }
 
   switch (aCx.mPhase) {
   case MiddlemanCallPhase::ReplayPreface:
     if (!HasDivergedFromRecording()) {
       // If we haven't diverged from the recording, use the output value saved
       // in the recording.
--- a/toolkit/recordreplay/ProcessRedirect.cpp
+++ b/toolkit/recordreplay/ProcessRedirect.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ProcessRedirect.h"
 
 #include "InfallibleVector.h"
 #include "MiddlemanCall.h"
+#include "ipc/ParentInternal.h"
 #include "mozilla/Sprintf.h"
 
 #include <dlfcn.h>
 #include <string.h>
 
 namespace {
 
 #include "udis86/udis86.c"
@@ -94,16 +95,21 @@ RecordReplayInterceptCall(int aCallId, C
     // If the redirection has a middleman call hook, try to perform the call in
     // the middleman instead.
     if (redirection.mMiddlemanCall) {
       if (SendCallToMiddleman(aCallId, aArguments, /* aPopulateOutput = */ true)) {
         return 0;
       }
     }
 
+    if (parent::InRepaintStressMode()) {
+      // We're about to crash, so print out the name of the call that failed.
+      Print("Could not perform middleman call: %s\n", redirection.mName);
+    }
+
     // Calling any redirection which performs the standard steps will cause
     // debugger operations that have diverged from the recording to fail.
     EnsureNotDivergedFromRecording();
     Unreachable();
   }
 
   if (IsRecording()) {
     // Call the original function, passing through events while we do so.