OSDN Git Service

Workaround problem reading main stack on intel devices.
authorDave Allison <dallison@google.com>
Mon, 18 Aug 2014 22:49:51 +0000 (15:49 -0700)
committerDave Allison <dallison@google.com>
Wed, 20 Aug 2014 02:00:43 +0000 (19:00 -0700)
This works around a problem where ART can't read the lowest page
of the main stack.  The workaround is to add 4K to the stack
start address on the main stack on Intel.

Please see https://b2.corp.google.com/issues/17111575 for
underlying cause.

Cherry picked from d970bac690baa6f735b0cd187440546869088a0f

Bug: 17031544
Change-Id: Ifc3216e10160bb1eec9d989fd57b10345bc89537

runtime/thread.cc

index d5163a8..7ac685b 100644 (file)
@@ -552,6 +552,17 @@ void Thread::InitStackHwm() {
     // The thread might have protected region at the bottom.  We need
     // to install our own region so we need to move the limits
     // of the stack to make room for it.
+
+#if defined(__i386__) || defined(__x86_64__)
+    // Work around issue trying to read last page of stack on Intel.
+    // The bug for this is b/17111575.  The problem is that we are
+    // unable to read the page just above the guard page on the
+    // main stack on an intel target.  When the bug is fixed
+    // this can be removed.
+    if (::art::GetTid() == getpid()) {
+      guardsize += 4 * KB;
+    }
+#endif
     tlsPtr_.stack_begin += guardsize + kStackOverflowProtectedSize;
     tlsPtr_.stack_end += guardsize + kStackOverflowProtectedSize;
     tlsPtr_.stack_size -= guardsize;