Use exit to avoid destructors in dex2oat.
(cherry picked from commit 2672a9f93caa66add6ca48a8e38ba1661ef43959)
Bug: 10645725
Change-Id: I55c2a7b7f3bd105f1a6a8bf84db2204c6f87e642
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 3848b6d..c4cce2f 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <valgrind.h>
#include <fstream>
#include <iostream>
@@ -1072,6 +1073,13 @@
if (dump_timing || (dump_slow_timing && timings.GetTotalNs() > MsToNs(1000))) {
LOG(INFO) << Dumpable<base::TimingLogger>(timings);
}
+
+ // Everything was successfully written, do an explicit exit here to avoid running Runtime
+ // destructors that take time (bug 10645725) unless we're a debug build or running on valgrind.
+ if (!kIsDebugBuild || (RUNNING_ON_VALGRIND == 0)) {
+ exit(EXIT_SUCCESS);
+ }
+
return EXIT_SUCCESS;
}