Bug 1279108 - Disable leak detection for updater xpcshell tests. r?mccr8 draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 10 Jun 2016 12:08:44 +0900
changeset 377472 e7fe22a437e25f4de7086c08ab79f336eb76e8c5
parent 377401 467c8c5d5fac1d6311790ec921040acbf9038e3a
child 523361 68e3497f9d1f5950b0e0c709f9b92b63d5499253
push id20804
push userbmo:mh+mozilla@glandium.org
push dateFri, 10 Jun 2016 13:47:37 +0000
reviewersmccr8
bugs1279108
milestone50.0a1
Bug 1279108 - Disable leak detection for updater xpcshell tests. r?mccr8 With more recent version of ASAN, the updater program shows multiple leaks, for different reasons. One is that the updater code heavily relies on pointers into a large buffer, with exceptions, making things difficult to avoid leaks of those exceptions. At least it requires more effort than I'm willing to put for the sake of upgrading the compiler we use for ASAN. Another is that the leak suppressions are not currently used for xpcshell tests, and some leaks attributed to libglib, that would normally be suppressed, are not. Moreover, even if the suppressions were used, it looks like some are not rooted to already suppressed system libraries, and would require investigation. Ideally, we'd have debug symbols installed for the system libraries and would have full stack traces, but we don't, so this makes the whole process harder than necessary. All in all, the updater is a separate short-lived program, and until we can address all the problems above, we can just ignore memory leaks in it (which aren't new anyways and are ignored by not being detected by the ASAN currently used on automation). We don't disable ASAN entirely, though, only leak detection, and only for the updater program.
toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
+++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
@@ -1611,21 +1611,40 @@ function runUpdate(aExpectedExitValue, a
       args[2] = applyToDirPath;
       args[3] = "0";
     }
     args = args.concat([callbackApp.parent.path, callbackApp.path]);
     args = args.concat(gCallbackArgs);
   }
   debugDump("running the updater: " + updateBin.path + " " + args.join(" "));
 
+  // See bug 1279108.
+  // nsIProcess doesn't have an API to pass a separate environment to the
+  // subprocess, so we need to alter the environment of the current process
+  // before launching the updater binary.
+  let env = Cc["@mozilla.org/process/environment;1"].
+            getService(Ci.nsIEnvironment);
+  let asan_options = null;
+  if (env.exists("ASAN_OPTIONS")) {
+    asan_options = env.get("ASAN_OPTIONS");
+    env.set("ASAN_OPTIONS", asan_options + ":detect_leaks=0")
+  } else {
+    env.set("ASAN_OPTIONS", "detect_leaks=0")
+  }
+
   let process = Cc["@mozilla.org/process/util;1"].
                 createInstance(Ci.nsIProcess);
   process.init(updateBin);
   process.run(true, args, args.length);
 
+  // Restore previous ASAN_OPTIONS if there were any.
+  if (asan_options !== null) {
+    env.set("ASAN_OPTIONS", asan_options);
+  }
+
   let status = readStatusFile();
   if (process.exitValue != aExpectedExitValue || status != aExpectedStatus) {
     if (process.exitValue != aExpectedExitValue) {
       logTestInfo("updater exited with unexpected value! Got: " +
                   process.exitValue + ", Expected: " +  aExpectedExitValue);
     }
     if (status != aExpectedStatus) {
       logTestInfo("update status is not the expected status! Got: " + status +