From 4936159997132d7706d9700c646f35ef0283df4b Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 22 Jan 2015 16:36:10 -0800 Subject: 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 --- runtime/monitor.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'runtime/monitor.cc') diff --git a/runtime/monitor.cc b/runtime/monitor.cc index ef63080649..5e3338042c 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -933,8 +933,11 @@ void Monitor::DescribeWait(std::ostream& os, const Thread* thread) { PrettyTypeOf(pretty_object).c_str()); } else { // - waiting on <0x6008c468> (a java.lang.Class) + // 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 -- cgit v1.2.3