Bug 1497716 - Add a redirection for realpath, r=froydnj.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 09 Oct 2018 14:32:55 -1000
changeset 498951 70309e4922792813c18320b1fdd64a5ef688feab
parent 498950 d85e5fb4421c39a263ea1268f39804a6c91f0bee
child 498952 77d431411954e637de7c035485d391cd775225f4
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1497716
milestone64.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 1497716 - Add a redirection for realpath, r=froydnj.
toolkit/recordreplay/ProcessRedirect.h
toolkit/recordreplay/ProcessRedirectDarwin.cpp
--- a/toolkit/recordreplay/ProcessRedirect.h
+++ b/toolkit/recordreplay/ProcessRedirect.h
@@ -320,17 +320,19 @@ NewLeakyArray(size_t aSize)
 // Record/replay a string rval.
 static inline void
 RR_CStringRval(Stream& aEvents, CallArguments* aArguments, ErrorType* aError)
 {
   auto& rval = aArguments->Rval<char*>();
   size_t len = (IsRecording() && rval) ? strlen(rval) + 1 : 0;
   aEvents.RecordOrReplayValue(&len);
   if (IsReplaying()) {
-    rval = len ? NewLeakyArray<char>(len) : nullptr;
+    // Note: Some users (e.g. realpath) require malloc to be used to allocate
+    // the returned buffer.
+    rval = len ? (char*) malloc(len) : nullptr;
   }
   if (len) {
     aEvents.RecordOrReplayBytes(rval, len);
   }
 }
 
 // Ensure that the return value matches the specified argument.
 template <size_t Argument>
--- a/toolkit/recordreplay/ProcessRedirectDarwin.cpp
+++ b/toolkit/recordreplay/ProcessRedirectDarwin.cpp
@@ -177,16 +177,22 @@ namespace recordreplay {
   MACRO(arc4random, RR_ScalarRval)                               \
   MACRO(mach_absolute_time, RR_ScalarRval, Preamble_mach_absolute_time) \
   MACRO(mach_msg, RR_Compose<RR_OrderCall, RR_ScalarRval, RR_WriteBuffer<0, 3>>) \
   MACRO(mach_timebase_info,                                      \
         RR_Compose<RR_ScalarRval, RR_WriteBufferFixedSize<0, sizeof(mach_timebase_info_data_t)>>) \
   MACRO(mach_vm_allocate, nullptr, Preamble_mach_vm_allocate)    \
   MACRO(mach_vm_deallocate, nullptr, Preamble_mach_vm_deallocate) \
   MACRO(mach_vm_protect, nullptr, Preamble_mach_vm_protect)      \
+  MACRO(realpath,                                                \
+        RR_SaveRvalHadErrorZero<RR_Compose<RR_CStringRval,       \
+                                           RR_WriteOptionalBufferFixedSize<1, PATH_MAX>>>) \
+  MACRO(realpath$DARWIN_EXTSN,                                   \
+        RR_SaveRvalHadErrorZero<RR_Compose<RR_CStringRval,       \
+                                           RR_WriteOptionalBufferFixedSize<1, PATH_MAX>>>) \
   /* By passing through events when initializing the sandbox, we ensure both */ \
   /* that we actually initialize the process sandbox while replaying as well as */ \
   /* while recording, and that any activity in these calls does not interfere */ \
   /* with the replay. */                                         \
   MACRO(sandbox_init, nullptr, Preamble_PassThrough)             \
   MACRO(sandbox_init_with_parameters, nullptr, Preamble_PassThrough) \
   /* Make sure events are passed through here so that replaying processes can */ \
   /* inspect their own threads. */                               \