summaryrefslogtreecommitdiffstats
path: root/runtime/thread.cc
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-07-22 06:51:47 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-07-21 15:45:44 +0000
commit9d9fec65366ea4996b17141c97ff94416239b63e (patch)
treeaab1773c63806c77f165822178d424486dfc8ef9 /runtime/thread.cc
parent7ff831f63111de69c71bc8c5cb1042d698b72070 (diff)
parent7ea6f79bbddd69d5db86a8656a31aaaf64ae2582 (diff)
downloadart-9d9fec65366ea4996b17141c97ff94416239b63e.zip
art-9d9fec65366ea4996b17141c97ff94416239b63e.tar.gz
art-9d9fec65366ea4996b17141c97ff94416239b63e.tar.bz2
Merge "ART: Throw StackOverflowError in native code"
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r--runtime/thread.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index ba5f9d4..8151464 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -76,6 +76,8 @@ namespace art {
bool Thread::is_started_ = false;
pthread_key_t Thread::pthread_key_self_;
ConditionVariable* Thread::resume_cond_ = nullptr;
+const size_t Thread::kStackOverflowImplicitCheckSize = kStackOverflowProtectedSize +
+ GetStackOverflowReservedBytes(kRuntimeISA);
static const char* kThreadNameDuringStartup = "<native thread without managed peer>";
@@ -219,7 +221,7 @@ static size_t FixStackSize(size_t stack_size) {
// It's likely that callers are trying to ensure they have at least a certain amount of
// stack space, so we should add our reserved space on top of what they requested, rather
// than implicitly take it away from them.
- stack_size += kRuntimeStackOverflowReservedBytes;
+ stack_size += GetStackOverflowReservedBytes(kRuntimeISA);
} else {
// If we are going to use implicit stack checks, allocate space for the protected
// region at the bottom of the stack.
@@ -308,7 +310,7 @@ void Thread::InstallImplicitProtection(bool is_main_stack) {
if (mprotect(pregion, kStackOverflowProtectedSize, PROT_NONE) == -1) {
LOG(FATAL) << "Unable to create protected region in stack for implicit overflow check. Reason:"
- << strerror(errno);
+ << strerror(errno) << kStackOverflowProtectedSize;
}
// Tell the kernel that we won't be needing these pages any more.
@@ -536,7 +538,7 @@ void Thread::InitStackHwm() {
tlsPtr_.stack_begin = reinterpret_cast<byte*>(read_stack_base);
tlsPtr_.stack_size = read_stack_size;
- if (read_stack_size <= kRuntimeStackOverflowReservedBytes) {
+ if (read_stack_size <= GetStackOverflowReservedBytes(kRuntimeISA)) {
LOG(FATAL) << "Attempt to attach a thread with a too-small stack (" << read_stack_size
<< " bytes)";
}
@@ -2247,7 +2249,7 @@ void Thread::SetStackEndForStackOverflow() {
if (tlsPtr_.stack_end == tlsPtr_.stack_begin) {
// However, we seem to have already extended to use the full stack.
LOG(ERROR) << "Need to increase kStackOverflowReservedBytes (currently "
- << kRuntimeStackOverflowReservedBytes << ")?";
+ << GetStackOverflowReservedBytes(kRuntimeISA) << ")?";
DumpStack(LOG(ERROR));
LOG(FATAL) << "Recursive stack overflow.";
}