summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.cc
diff options
context:
space:
mode:
authorHaifeng Li <omycle@gmail.com>2014-05-16 10:47:59 +0800
committerMathieu Chartier <mathieuc@google.com>2014-05-16 09:36:58 -0700
commit86ab7912423f63541073af5c487b509e9b2b5420 (patch)
treebdf2cda5bd949a5577fe9a64c708731378c8ba6c /runtime/monitor.cc
parente1a71b2a6e899645b006c29ba37695f521545a5b (diff)
downloadart-86ab7912423f63541073af5c487b509e9b2b5420.zip
art-86ab7912423f63541073af5c487b509e9b2b5420.tar.gz
art-86ab7912423f63541073af5c487b509e9b2b5420.tar.bz2
ART: Fix Segment Fault with null owner while monitor logging is enabled
When the monitor inflates from thin to fat with the existing hashcode, the owner is nullptr, which will cause segment fault with owner->GetThreadId(). Change-Id: I90081d581a0ffd3d38763cc175fd2d7f66076747
Diffstat (limited to 'runtime/monitor.cc')
-rw-r--r--runtime/monitor.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 64edba8..53e4a6f 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -625,8 +625,13 @@ void Monitor::Inflate(Thread* self, Thread* owner, mirror::Object* obj, int32_t
// Allocate and acquire a new monitor.
UniquePtr<Monitor> m(new Monitor(self, owner, obj, hash_code));
if (m->Install(self)) {
- VLOG(monitor) << "monitor: thread " << owner->GetThreadId()
- << " created monitor " << m.get() << " for object " << obj;
+ if (owner != nullptr) {
+ VLOG(monitor) << "monitor: thread" << owner->GetThreadId()
+ << " created monitor " << m.get() << " for object " << obj;
+ } else {
+ VLOG(monitor) << "monitor: Inflate with hashcode " << hash_code
+ << " created monitor " << m.get() << " for object " << obj;
+ }
Runtime::Current()->GetMonitorList()->Add(m.release());
CHECK_EQ(obj->GetLockWord(true).GetState(), LockWord::kFatLocked);
}