summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd_test.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2019-07-15 17:13:24 -0700
committerChristopher Ferris <cferris@google.com>2019-07-17 14:14:26 -0700
commit481e8379d39440f8d94b17c8ebb8aa99c7c4433f (patch)
tree7b0225e3ae3d190578fb3d8a927dc53e6672f3f3 /debuggerd/debuggerd_test.cpp
parentc37f4a41990bb1f6e17cf4a56b8c00371d7054e1 (diff)
Add cause message when stack overflow is detected.
Test: Ran new unit tests. Test: Ran crasher stack-overflow, crasher64 stack-overflow and verified Test: stack overflow cause is shown. Test: Ran stack overflow app and verified tombstone includes stack-overflow Test: message. Change-Id: I9bb01186dff5ed81c77d84b6aaedb5332ddd7256
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r--debuggerd/debuggerd_test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index 1f0e4201e..fbc8b9706 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -1099,3 +1099,30 @@ TEST(tombstoned, interceptless_backtrace) {
// This should be good enough, though...
ASSERT_LT(diff, 10) << "too many new tombstones; is something crashing in the background?";
}
+
+static __attribute__((__noinline__)) void overflow_stack(void* p) {
+ void* buf[1];
+ buf[0] = p;
+ static volatile void* global = buf;
+ if (global) {
+ global = buf;
+ overflow_stack(&buf);
+ }
+}
+
+TEST_F(CrasherTest, stack_overflow) {
+ int intercept_result;
+ unique_fd output_fd;
+ StartProcess([]() { overflow_stack(nullptr); });
+
+ StartIntercept(&output_fd);
+ FinishCrasher();
+ AssertDeath(SIGSEGV);
+ FinishIntercept(&intercept_result);
+
+ ASSERT_EQ(1, intercept_result) << "tombstoned reported failure";
+
+ std::string result;
+ ConsumeFd(std::move(output_fd), &result);
+ ASSERT_MATCH(result, R"(Cause: stack pointer[^\n]*stack overflow.\n)");
+}