[kaffe] CVS kaffe (guilhem): Implemented stack overflow detection.

Guilhem Lavaux guilhem at kaffe.org
Thu Apr 22 23:32:02 PDT 2004


On Thu, 2004-04-22 at 23:08, Timothy Stack wrote:
> > Implemented stack overflow detection.
> 
> Can you give us a more detailed explanation of what this all is?
> 

Sure. I was writing some comments in the code now. I wanted to be able
to detect stack overflows like null pointer exception. There were two
problems for that: detect the real boundaries of the stack and be able
to run the signal handlers on another stack.

detectStackBoundaries() sets up a temporary signal handler for SIGSEGV,
places a jump point and tries to overflow the stack using a recursive
function (infiniteLoop). This is the slowest part of the code indeed
because if the stack is very large you may have to wait some time before
reaching the end of it... Anyway, when the stack end is reached a
sigsegv is raised. This gives us the state of the stack pointer when the
segv occured and so one of the boundary of the stack. With getrlimit you
get the other boundary of the stack using its size.

Now to detect stack overflows while running programs you also only have
to check the stack pointer. If it is outside of the boundaries while a
segv is raised we have to throw a StackOverflowError, in the other case
it is NullPointerException.

This code is entirely optional, in case sigaltstack, SA_ONSTACK or
STACK_POINTER is not defined, the old buggy behaviour is used.

For the moment the behaviour in the jitted code has not been changed.

Cheers,

Guilhem.

> thanks,
> 
> tim
> 
> _______________________________________________
> kaffe mailing list
> kaffe at kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe





More information about the kaffe mailing list