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 Friday, February 7, 2003, at 11:03  PM, Fergus Henderson wrote:

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 is such a bad idea it's hard to start explaining why it will never happen. Consider, for instance, what would happen if the user program is really a database server that has closed stdin/stdout/stderr and happens to have fd 2 open on its database backing store.

Incidentally, why does stack overflow result in SIGBUS on Darwin rather
than SIGSEGV?  Posix mandates that stack overflow result in SIGSEGV.
I'm not sure exactly what happens, but I'm pretty sure it starts with SIGSEGV being raised, then the kernel attempts to create a signal frame on the already-full stack. You'll notice that host-darwin.c does catch SIGSEGV.

--
Geoff Keating <geoffk@apple.com>


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