This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: allocation on the stack


Thomas van Gulick asks how to catch stack overflow and continue running.

On those OSes which support it (Linux-2.2 with glibc-2.1, Solaris, OSF/1,
Win32, maybe Irix), you can catch stack overflow using the sigsegv library
[1]. But be warned that it's really hairy stuff, and is not reliable because
it needs heuristics to distinguish a stack overflow from a regular SIGSEGV.

If your problem is not infinite recursion but huge arrays, it's a good idea
to allocate temporary memory with alloca when it's small (say, < 64 KB),
and with malloc when it's large.

                  Bruno


[1] ftp://ftp.santafe.edu/pub/gnu/sigsegv-1.1.tar.gz

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]