2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-19 04:02:17 +00:00

test bug 12592

This commit is contained in:
Oliver Kowalke
2017-01-21 14:52:19 +01:00
parent 1f53a8825d
commit 5544120b47
2 changed files with 40 additions and 0 deletions

View File

@@ -70,6 +70,10 @@ exe endless_loop
: endless_loop.cpp
;
exe stack_alignment
: stack_alignment.cpp
;
#exe backtrace
# : backtrace.cpp
# ;

View File

@@ -0,0 +1,36 @@
#include <cstdlib>
#include <cstring>
#include <array>
#include <iostream>
#include <boost/context/continuation.hpp>
void stack_overflow(int n)
{
// Silence warnings about infinite recursion
if (n == 0xdeadbeef) return;
// Allocate more than 4k bytes on the stack.
std::array<char, 8192> blob;
// Repeat...
stack_overflow(n + 1);
// Prevent blob from being optimized away
std::memcpy(blob.data(), blob.data(), n);
std::cout << blob.data();
}
int main(int argc, char* argv[])
{
using namespace boost::context;
// Calling stack_overflow outside of Boost context results in a regular stack
// overflow exception.
// stack_overflow(0);
callcc([](continuation && sink) {
// Calling stack_overflow inside results in a memory access violation caused
// by the compiler generated _chkstk function.
stack_overflow(0);
return std::move( sink);
});
return EXIT_SUCCESS;
}