Bug 1386404 - Whitelist the prefix used by the XPCOM leak logs. r?haik draft
authorGian-Carlo Pascutto <gcp@mozilla.com>
Fri, 03 Nov 2017 13:18:56 +0100
changeset 749381 b39d5fecfea05b0bce6aebd50d922d9fe49aa98f
parent 749380 8f60c28b351faff34842ab0aa4dc0a6ff2604cab
child 749382 50aaccec621d74e51db06dc2cb3d6cd2319d43d7
push id97374
push usergpascutto@mozilla.com
push dateWed, 31 Jan 2018 09:19:12 +0000
reviewershaik
bugs1386404
milestone60.0a1
Bug 1386404 - Whitelist the prefix used by the XPCOM leak logs. r?haik MozReview-Commit-ID: HI68lvyJIPQ
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -381,16 +381,32 @@ SandboxBrokerPolicyFactory::SandboxBroke
     // Therefore in non-release builds we allow reads from the whole repository.
     // MOZ_DEVELOPER_REPO_DIR is set by mach run.
     const char *developer_repo_dir = PR_GetEnv("MOZ_DEVELOPER_REPO_DIR");
     if (developer_repo_dir) {
       policy->AddDir(rdonly, developer_repo_dir);
     }
   }
 
+#ifdef DEBUG
+  char *bloatLog = PR_GetEnv("XPCOM_MEM_BLOAT_LOG");
+  // XPCOM_MEM_BLOAT_LOG has the format
+  // /tmp/tmpd0YzFZ.mozrunner/runtests_leaks.log
+  // but stores into /tmp/tmpd0YzFZ.mozrunner/runtests_leaks_tab_pid3411.log
+  // So cut the .log part and whitelist the prefix.
+  if (bloatLog != nullptr) {
+    size_t bloatLen = strlen(bloatLog);
+    if (bloatLen >= 4) {
+      nsAutoCString bloatStr(bloatLog);
+      bloatStr.Truncate(bloatLen - 4);
+      policy->AddPrefix(rdwrcr, bloatStr.get());
+    }
+  }
+#endif
+
   mCommonContentPolicy.reset(policy);
 #endif
 }
 
 #ifdef MOZ_CONTENT_SANDBOX
 UniquePtr<SandboxBroker::Policy>
 SandboxBrokerPolicyFactory::GetContentPolicy(int aPid, bool aFileProcess)
 {