
20 Jan
2017
20 Jan
'17
7:47 a.m.
2017-01-18 20:38 GMT+01:00 Gregory Laird
Question: If I allocate too small of a stack, and something gets written outside of the allocation, is there any way to know that this has occurred?
In the best case you get a segmentation fault (in worst case you get undefined behaviour). You could use the protected_fixedsize_stack allocator - it appends a guard page at the end of the stack (only virtual addresses, no physical memory is wasted). If you try to access memory from the guard page you get a segmentation fault. Another possibility is to use the segmented_stack allocator. It extends the stack on demand (supported by gcc-4.7 onwards) - but you are forced to use execution_context v1.