Greg Troxel <[email protected]> wrote: > * I'd say it's a bug in emacs if emacs crashes rather than prints a > message about stack size.
It's a bit of a pain to do it, so most programs don't bother. When a program exceeds its stack limit it gets a SIGSEGV for the stack address at some random point. It may happen when stack frame is created and the registers you save spill over to the page that is over the limit. Or it may happen later in the function when you access a local variable that is in the part of the stack that is over the limit. You need to have a SIGSEGV handler with an alternative stack (or you would incur recursive SIGSEGV), examine the fault address, examine the mcontext and determine that the fault address is a stack address. You need to know if your stack grows up or down. If you have a really big frame, the fault address may not be on the page adjacent to the page where the stack pointer is. Etc, etc, etc. So most programs just dump core at the offending instruction and you can at least easily figure out what happened. -uwe
