diff --git a/test/suicide.cpp b/test/suicide.cpp index 2e1ba2a..8b3955b 100644 --- a/test/suicide.cpp +++ b/test/suicide.cpp @@ -23,7 +23,8 @@ #include "backward.hpp" -#include +#include +#include #include "test/test.hpp" using namespace backward; @@ -77,3 +78,16 @@ TEST_DIVZERO (divide_by_zero) int v = divide_by_zero(); std::cout << "v=" << v << std::endl; } + +int bye_bye_stack(int i) { + return bye_bye_stack(i + 1) + bye_bye_stack(i * 2); +} + +TEST_SEGFAULT(stackoverflow) +{ + struct rlimit limit; + limit.rlim_max = 8096; + setrlimit(RLIMIT_STACK, &limit); + int r = bye_bye_stack(42); + std::cout << "r=" << r << std::endl; +}