Fix and re-enable CMS
Fix for CardTable::Scan double length scan which caused occasional assert failures.
Fix for the case where CMS request JNI code caused a GC which freed newest allocated object.
Fix error with is_gc_running_ never being set and deadlock due to CV wait without thread state change.
Fix error where we were Unlocking the heap before doing ResumeAll in CollectGarbageInternal which resulted in a rare race condition.
Fix error where GC could be in progress when the runtime terminated.
Change-Id: I8d243d4dca63170433a63429442788ecb09e55fe
diff --git a/src/runtime.cc b/src/runtime.cc
index dda8f62..37c9dce 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -35,6 +35,7 @@
#include "jni_internal.h"
#include "monitor.h"
#include "oat_file.h"
+#include "scoped_heap_lock.h"
#include "ScopedLocalRef.h"
#include "signal_catcher.h"
#include "signal_set.h"
@@ -94,6 +95,12 @@
Trace::Shutdown();
}
+ // Make sure to let the GC complete if it is running.
+ {
+ ScopedHeapLock heap_lock;
+ heap_->WaitForConcurrentGcToComplete();
+ }
+
// Make sure our internal threads are dead before we start tearing down things they're using.
Dbg::StopJdwp();
delete signal_catcher_;