Stack variables
Jeffrey A Law
law@unknown
Tue Jan 20 10:07:00 GMT 1998
In message < 199801172114.XAA24914@fishy.pp.sci.fi >you write:
> Since there were no checks, it eventually overwrote its stack. When I
> debugged it with GDB, I just got a notification "SIGSEGV received", and
> stack trace gave only one address: 0. Nothing else. Eventually I figured
> it out, but I think that it shouldn't be this easy to screw your stack..
Welcome to the wonderful world of unix.
> I usually use Electric Fence to debug programs, but in this case it was of
> no use since it can't put an unmapped page before/after a stack variable.
> After a while I thought of a simple solution: What about having a
> debugging option in gcc that would allocate all stack variables with
> malloc()? This would slow down the program, yes, but since it would be a
> debugging option, it wouldn't matter.
It's an interesting thought, but separating the stack variables from
other uses of the stack might be rather difficult. There's also significant
code in the compiler which knows special things about the stack or frame
poiner (look for stack_pointer_rtx in reload*.c and many other files).
jeff
More information about the Gcc
mailing list