Merge "Only allow one thread to abort at a time." into dalvik-dev
diff --git a/src/runtime.cc b/src/runtime.cc
index c70ca77..6a454a0 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -33,6 +33,8 @@
 
 Runtime* Runtime::instance_ = NULL;
 
+Mutex Runtime::abort_lock_("abort lock");
+
 Runtime::Runtime()
     : is_zygote_(false),
       default_stack_size_(Thread::kDefaultStackSize),
@@ -107,6 +109,10 @@
 };
 
 void Runtime::Abort(const char* file, int line) {
+  // Ensure that we don't have multiple threads trying to abort at once,
+  // which would result in significantly worse diagnostics.
+  MutexLock mu(abort_lock_);
+
   // Get any pending output out of the way.
   fflush(NULL);
 
diff --git a/src/runtime.h b/src/runtime.h
index 2b3fd7e..f950add 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -285,6 +285,8 @@
   // A pointer to the active runtime or NULL.
   static Runtime* instance_;
 
+  static Mutex abort_lock_;
+
   DISALLOW_COPY_AND_ASSIGN(Runtime);
 };