Fix compaction unsafe DescribeWait
Fixes a crash that was seen once in automated tests, PrettyTypeOf
was accessing a stale object which had moved during IdentityHashCode
due to thin lock inflation causing suspension.
Change-Id: I105aa9a09d4e8c9091b9a60e508ef71e613f1eed
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index ef63080..5e33380 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -933,8 +933,11 @@
PrettyTypeOf(pretty_object).c_str());
} else {
// - waiting on <0x6008c468> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
+ // Call PrettyTypeOf before IdentityHashCode since IdentityHashCode can cause thread
+ // suspension and move pretty_object.
+ const std::string pretty_type(PrettyTypeOf(pretty_object));
os << wait_message << StringPrintf("<0x%08x> (a %s)", pretty_object->IdentityHashCode(),
- PrettyTypeOf(pretty_object).c_str());
+ pretty_type.c_str());
}
}
// - waiting to lock <0x613f83d8> (a java.lang.Object) held by thread 5