diff options
| author | 2015-04-30 06:53:35 +0000 | |
|---|---|---|
| committer | 2015-04-30 06:53:36 +0000 | |
| commit | dacee9200210fca06e01e5967f7265e11b2942d4 (patch) | |
| tree | 36649acaad2a977533354cda13653c7d89115d06 | |
| parent | eff3229ff3c8faead4b6d400e273ee27b7004dab (diff) | |
| parent | b81e1cddd6a8ccccb9fe86e3bfae12b2657b8085 (diff) | |
Merge "Fix missing transaction abort error message"
| -rw-r--r-- | runtime/runtime.cc | 5 | ||||
| -rw-r--r-- | runtime/transaction.cc | 14 | ||||
| -rw-r--r-- | runtime/transaction.h | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index eb603186cd..2633898b32 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1566,14 +1566,15 @@ void Runtime::AbortTransactionAndThrowAbortError(Thread* self, const std::string // Throwing an exception may cause its class initialization. If we mark the transaction // aborted before that, we may warn with a false alarm. Throwing the exception before // marking the transaction aborted avoids that. - preinitialization_transaction_->ThrowAbortError(self, false); + preinitialization_transaction_->ThrowAbortError(self, &abort_message); preinitialization_transaction_->Abort(abort_message); } void Runtime::ThrowTransactionAbortError(Thread* self) { DCHECK(IsAotCompiler()); DCHECK(IsActiveTransaction()); - preinitialization_transaction_->ThrowAbortError(self, true); + // Passing nullptr means we rethrow an exception with the earlier transaction abort message. + preinitialization_transaction_->ThrowAbortError(self, nullptr); } void Runtime::RecordWriteFieldBoolean(mirror::Object* obj, MemberOffset field_offset, diff --git a/runtime/transaction.cc b/runtime/transaction.cc index cc0f15f6f2..ab821d7714 100644 --- a/runtime/transaction.cc +++ b/runtime/transaction.cc @@ -70,13 +70,21 @@ void Transaction::Abort(const std::string& abort_message) { } } -void Transaction::ThrowAbortError(Thread* self, bool rethrow) { +void Transaction::ThrowAbortError(Thread* self, const std::string* abort_message) { + const bool rethrow = (abort_message == nullptr); if (kIsDebugBuild && rethrow) { CHECK(IsAborted()) << "Rethrow " << Transaction::kAbortExceptionDescriptor << " while transaction is not aborted"; } - std::string abort_msg(GetAbortMessage()); - self->ThrowNewWrappedException(Transaction::kAbortExceptionSignature, abort_msg.c_str()); + if (rethrow) { + // Rethrow an exception with the earlier abort message stored in the transaction. + self->ThrowNewWrappedException(Transaction::kAbortExceptionSignature, + GetAbortMessage().c_str()); + } else { + // Throw an exception with the given abort message. + self->ThrowNewWrappedException(Transaction::kAbortExceptionSignature, + abort_message->c_str()); + } } bool Transaction::IsAborted() { diff --git a/runtime/transaction.h b/runtime/transaction.h index 4d856625c2..030478c7ad 100644 --- a/runtime/transaction.h +++ b/runtime/transaction.h @@ -48,7 +48,7 @@ class Transaction FINAL { void Abort(const std::string& abort_message) LOCKS_EXCLUDED(log_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ThrowAbortError(Thread* self, bool rethrow) + void ThrowAbortError(Thread* self, const std::string* abort_message) LOCKS_EXCLUDED(log_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsAborted() LOCKS_EXCLUDED(log_lock_); |