ART: Reserve more overflow space for the interpreter
In debuggable builds, especially under ASAN, the switch interpreter
with access-checks has a huge stack frame. Virtually increase the
protected stack space at the end for overflow handling. This is
necessary so that interpreter calls will create a StackOverflow
before it is too late.
Technically only ASAN pushes the stack over the established limit,
but there is no practical downside to adding a small amount to the
overflow (note that the reserved size is small for non-ASAN builds),
and this avoids the proliferation of memory_tool.h.
Non-debug builds are approximately protected by frame-size compiler
checks. Compiled code does not need additional space, as the actual
overflow handling fits into the carved-out space.
Bug: 109813469
Test: SANITIZE_HOST=address art/test/testrunner/testrunner.py -b --host --interp-ac -t 004-SignalTest
Change-Id: I1bdd2fc586a6da30720a8be62f3247180ce48e93
diff --git a/runtime/thread.h b/runtime/thread.h
index 3ec050a..c8a4b61 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -817,13 +817,17 @@
}
uint8_t* GetStackEndForInterpreter(bool implicit_overflow_check) const {
- if (implicit_overflow_check) {
- // The interpreter needs the extra overflow bytes that stack_end does
- // not include.
- return tlsPtr_.stack_end + GetStackOverflowReservedBytes(kRuntimeISA);
- } else {
- return tlsPtr_.stack_end;
+ uint8_t* end = tlsPtr_.stack_end + (implicit_overflow_check
+ ? GetStackOverflowReservedBytes(kRuntimeISA)
+ : 0);
+ if (kIsDebugBuild) {
+ // In a debuggable build, but especially under ASAN, the access-checks interpreter has a
+ // potentially humongous stack size. We don't want to take too much of the stack regularly,
+ // so do not increase the regular reserved size (for compiled code etc) and only report the
+ // virtually smaller stack to the interpreter here.
+ end += GetStackOverflowReservedBytes(kRuntimeISA);
}
+ return end;
}
uint8_t* GetStackEnd() const {