Fix a CC crash with ThreadStress.

Add a read barrier on the locked object in Monitor::DescribeWait().

Bug: 31848261
Bug: 12687968
Test: test-art-host with CC and N9 libartd boot.
Change-Id: I569e1499c2aadf54d9074a8a790e5d512c2dad4f
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 3bc1b06..debbdd5 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -1123,6 +1123,13 @@
     wait_message = "  - waiting to lock ";
     pretty_object = thread->GetMonitorEnterObject();
     if (pretty_object != nullptr) {
+      if (kUseReadBarrier && Thread::Current()->GetIsGcMarking()) {
+        // We may call Thread::Dump() in the middle of the CC thread flip and this thread's stack
+        // may have not been flipped yet and "pretty_object" may be a from-space (stale) ref, in
+        // which case the GetLockOwnerThreadId() call below will crash. So explicitly mark/forward
+        // it here.
+        pretty_object = ReadBarrier::Mark(pretty_object);
+      }
       lock_owner = pretty_object->GetLockOwnerThreadId();
     }
   }