This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: 'stack overflow' message for Darwin; host hooks


On 07-Feb-2003, Geoffrey Keating <geoffk@apple.com> wrote:
> 
> On Friday, February 7, 2003, at 08:01  AM, Fergus Henderson wrote:
> 
> >If an application runs out of stack space,
> >why would it *ever* be better to issue the error message "Bus Error"
> >rather than "Stack Overflow"??
> 
> Right, but that's not this patch; that would require kernel changes to 
> change the signal sent.  If you look at where the 'bus error' message 
> comes from, it's because the signal sent is (reported as) SIGBUS.  To 
> get a different message, you'd need to report some other signal.  Then 
> you get into issues about backwards binary compatibility...
...
> All this is interesting, but it's not really a GCC issue.  Feel free to 
> lobby the FreeBSD or Darwin folks for a SIGSTKOVERFLOW or whatever.

Changing which signal is sent would be nice in the long term, but that
could indeed cause backwards compatibility problems, so I'm not suggesting
that.  Instead, I'm suggesting just changing the default behaviour when
a SIGBUS signal is received and the current signal handler for SIGBUS
is SIG_DFL.  The default behaviour should IMHO be to print a reasonable
error message to stderr before terminating the process. 

This solution is not perfect, since you may get two error messages,
one from the application, and one from the invoking process (e.g.
the shell), and the second one won't say anything about stack overflow.
However, I think this solution would be good enough.

If this solution was adopted, then I don't think your patch to GCC would
be needed.  So I see your patch as kludging around a deficiency of the
underlying system.  IMHO it would be better to fix the underlying system
rather than patching GCC.

P.S.
Incidentally, why does stack overflow result in SIGBUS on Darwin rather
than SIGSEGV?  Posix mandates that stack overflow result in SIGSEGV.
[Reference: IEEE Std 1003.1-2001; see the description of RLIMIT_STACK
in the specification for getrlimit() and setrlimit().]

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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