vicare icon indicating copy to clipboard operation
vicare copied to clipboard

Scheme stack overflow is possible

Open marcomaggi opened this issue 11 years ago • 2 comments

There is no true stack overflow prevention check; a check is present, but it does not guarantee to always detect the danger. Even though it is unlikely to happen, a Scheme stack overflow can happen.

marcomaggi avatar Apr 15 '13 07:04 marcomaggi

Here is an idea to at least avoid memory corruption: allocate one more stack page and disallow read and write with "mprotect()". When allocating:

mprotect(pcb->stack_base, getpagesize(), PROT_NONE);

when releasing or recofiguring from stack segment to data segment:

mprotect(stack, getpagesize(), PROT_READ|PROT_WRITE);

This is from http://www.rethinkdb.com/blog/handling-stack-overflow-on-custom-stacks/.

marcomaggi avatar Apr 15 '13 09:04 marcomaggi

Last page protection is now implemented in the head of the devel branch.

marcomaggi avatar Apr 15 '13 18:04 marcomaggi