Fix the mutex diagnostics, and other targets of opportunity.

Three changes for the price of one:

1. Fix the mutex diagnostics so they work right during startup and shutdown.

2. Fix a memory leak in common_test.

3. Fix memory corruption in the compiler; we were calling memset(3) on a struct
with non-POD members.

Thanks, as usual, to valgrind(1) for the latter two (and several bugs in
earlier attempts at the former).

Change-Id: I15e1ffb01e73e4c56a5bbdcaa7233a4b5221e08a
diff --git a/src/common_test.h b/src/common_test.h
index 74056c9..3d5b53b 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -366,7 +366,8 @@
       }
     }
     class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
-    compiler_.reset(new Compiler(instruction_set, true, 2, false, new std::set<std::string>,
+    image_classes_.reset(new std::set<std::string>);
+    compiler_.reset(new Compiler(instruction_set, true, 2, false, image_classes_.get(),
                                  true, true));
 #if defined(ART_USE_LLVM_COMPILER)
     compiler_->EnableAutoElfLoading();
@@ -413,6 +414,7 @@
     (*icu_cleanup_fn)();
 
     compiler_.reset();
+    image_classes_.reset();
     STLDeleteElements(&opened_dex_files_);
 
     Runtime::Current()->GetHeap()->VerifyHeap();  // Check for heap corruption after the test
@@ -512,6 +514,7 @@
   // Owned by the runtime
   ClassLinker* class_linker_;
   UniquePtr<Compiler> compiler_;
+  UniquePtr<std::set<std::string> > image_classes_;
 
  private:
   std::vector<const DexFile*> opened_dex_files_;