summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brian Carlstrom <bdc@google.com> 2012-11-05 19:21:30 -0800
committer Brian Carlstrom <bdc@google.com> 2012-11-05 19:22:24 -0800
commit81b8871007101f42e2baabf213e1312004073eb0 (patch)
tree7664b7ebf5dabeb0364806d1312299020c77c1d4
parentbcc2926b9721f94c17ed98fae5264cc98f0e066f (diff)
Broaden scope of gAborting. Fixes hang in HandleUnexpectedSignal.
Change-Id: I4c29cd7b67f07bb9f99c308feac5a3d6c236bc2b
-rw-r--r--src/logging.cc2
-rw-r--r--src/logging.h5
-rw-r--r--src/mutex.h2
-rw-r--r--src/runtime.cc4
-rw-r--r--src/runtime_linux.cc1
5 files changed, 11 insertions, 3 deletions
diff --git a/src/logging.cc b/src/logging.cc
index 5680ed0a34..9dde963895 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -25,6 +25,8 @@ namespace art {
LogVerbosity gLogVerbosity;
+bool gAborting = false;
+
static LogSeverity gMinimumLogSeverity = INFO;
static std::string* gCmdLine;
static std::string* gProgramInvocationName;
diff --git a/src/logging.h b/src/logging.h
index 75782d5640..d0d35ea453 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -318,6 +318,11 @@ struct LogVerbosity {
};
extern LogVerbosity gLogVerbosity;
+
+// Used on fatal exit. Prevents recursive aborts. Allows us to disable
+// some error checking to ensure fatal shutdown makes forward progress.
+extern bool gAborting;
+
extern void InitLogging(char* argv[]);
extern const char* GetCmdLine();
diff --git a/src/mutex.h b/src/mutex.h
index 4af2ad7d0a..d0c636926d 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -107,7 +107,7 @@ class LOCKABLE Mutex : public BaseMutex {
// Assert that the Mutex is exclusively held by the current thread.
void AssertExclusiveHeld(const Thread* self) {
- if (kDebugLocking) {
+ if (kDebugLocking && !gAborting) {
CHECK(IsExclusiveHeld(self)) << *this;
}
}
diff --git a/src/runtime.cc b/src/runtime.cc
index 79d1fb2604..afe0a42aef 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -153,8 +153,6 @@ Runtime::~Runtime() {
instance_ = NULL;
}
-static bool gAborting = false;
-
struct AbortState {
void Dump(std::ostream& os) {
if (gAborting) {
@@ -200,6 +198,8 @@ struct AbortState {
};
void Runtime::Abort() {
+ gAborting = true; // set before taking any locks
+
// Ensure that we don't have multiple threads trying to abort at once,
// which would result in significantly worse diagnostics.
MutexLock mu(Thread::Current(), *Locks::abort_lock_);
diff --git a/src/runtime_linux.cc b/src/runtime_linux.cc
index 01c08d3110..430c70f4d9 100644
--- a/src/runtime_linux.cc
+++ b/src/runtime_linux.cc
@@ -228,6 +228,7 @@ struct UContext {
};
static void HandleUnexpectedSignal(int signal_number, siginfo_t* info, void* raw_context) {
+ gAborting = true; // set before taking any locks
MutexLock mu(Thread::Current(), *Locks::unexpected_signal_lock_);
bool has_address = (signal_number == SIGILL || signal_number == SIGBUS ||