From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geoff Keating To: Anthony Green Cc: "Earl S. Harris, Jr." , gcc@gcc.gnu.org Subject: Re: Catching stack overflow errors Date: Fri, 11 Aug 2000 15:57:00 -0000 Message-id: References: <200008042104.RAA06398@mal-ach.watson.ibm.com> <398EAF45.57B340A5@mitre.org> X-SW-Source: 2000-08/msg00269.html Anthony Green writes: > "Earl S. Harris, Jr." writes: > > I think this is important if the following conditions hold. > > > > 1. A programmer wants to use non tail recursion in his/her C++ program. > > 2. He/she doesn't want the program to crash inelegantly. > > It is also important for other languages supported by GCC. Java > implementations are required to throw exceptions when a stack is blown > but gcj currently ignores this. There are some features in the development gcc that let you detect stack overflows, if the usual OS signal-handling isn't robust enough for you. Look at the -fstack-limit-* options. It has to be used in a processor-specific way, but it does guarantee that you will get a SIGTRAP _before_ the stack is expanded (rather than after all the damage is done). You can then catch the signal and deal with it by, for instance, calling siglongjmp(). -- - Geoffrey Keating