summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2014-01-15 13:30:54 -0800
committer Mathieu Chartier <mathieuc@google.com> 2014-01-15 15:15:22 -0800
commitce4689ff0ed3318a2429cf30c72ed6df6dbe905c (patch)
tree3abace19988691eef3848b7d240c5cc9376140a2
parente99f8c81be6bb3fbe4a0b5658b2c039f56d13361 (diff)
Run checkpoints after resuming threads in signal catcher SIGQUIT.
Previously we were running checkpoints after restoring the thread state, but before resuming the threads. This caused an issue with profiler checkpoints since these use a ScopedObjectAccess. Since we had with exclusive access to the mutator lock when we ran the checkpoints, it caused deadlocks when we tried to gain shared access to the mutator lock in the ScopedThreadStateChange if the old_state was any state other than kRunnable. Bug: 12490061 Change-Id: I5f922693a4bf5d18cf9d22f1f28a7a04b6bfc077
-rw-r--r--runtime/signal_catcher.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/signal_catcher.cc b/runtime/signal_catcher.cc
index fe62e25443..611c0a85a6 100644
--- a/runtime/signal_catcher.cc
+++ b/runtime/signal_catcher.cc
@@ -145,12 +145,13 @@ void SignalCatcher::HandleSigQuit() {
}
os << "----- end " << getpid() << " -----\n";
CHECK_EQ(self->SetStateUnsafe(old_state), kRunnable);
+ self->EndAssertNoThreadSuspension(old_cause);
+ thread_list->ResumeAll();
+ // Run the checkpoints after resuming the threads to prevent deadlocks if the checkpoint function
+ // acquires the mutator lock.
if (self->ReadFlag(kCheckpointRequest)) {
self->RunCheckpointFunction();
}
- self->EndAssertNoThreadSuspension(old_cause);
- thread_list->ResumeAll();
-
Output(os.str());
}