From: Xi Ruoyao <xry111@mengyan1223.wang>
To: Jonny Grant <jg@jguk.org>, Florian Weimer <fw@deneb.enyo.de>,
Andrew Haley <aph@redhat.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Recursive SIGSEGV question
Date: Tue, 26 Mar 2019 06:50:00 -0000 [thread overview]
Message-ID: <39fcf2609f20b7f6187ebf5f1f26fb01081eab5d.camel@mengyan1223.wang> (raw)
In-Reply-To: <b9df1315-c6d0-b773-7d3d-ba0723858cbc@jguk.org>
On 2019-03-25 20:28 +0000, Jonny Grant wrote:
> Hi!
>
> On 25/03/2019 17:14, Florian Weimer wrote:
> > * Andrew Haley:
> >
> > > On 3/25/19 2:01 PM, Florian Weimer wrote:
> > > > * Xi Ruoyao:
> > > >
> > > > > On 2019-03-25 13:06 +0000, Jonny Grant wrote:
> > > > > > I built & ran with the Sanitizer, it seems it's also stack overflow
> > > > > > within the operator new()
> > > > > >
> > > > > > I had thoughts GCC would generate code that monitored the stack size
> > > > > > and
> > > > > > aborted with a clear message when the stack size was exceeded.
> > > > > > Looked
> > > > > > online, and it doesn't seem to be the case.
> > > > >
> > > > > Impossible. We can't distinguish "stack overflow" with other
> > > > > segmentation
> > > > > faults.
> > > >
> > > > I think âimpossibleâ is too strong.
> > >
> > > It is. We do it with stack banging and a few guard pages in the HotSpot
> > > JVM.
> > > The problem is that recovering well enough to throw an exception requires
> > > some quite hairy non-portable code.
> >
> > Of course it's going to be non-portable. Ideally, this would be
> > handled out-of-process: the shell registers itself with the system
> > coredump handler, and the handler analyzes the crash and provides
> > information back to the shell for display.
> >
> > It's quite difficult to get there, but it's certainly not impossible.
> > We really should have lightweight tracebacks for aborts and the like
> > in C/C++ code. Right now, every moderately large piece of software
> > tries to write their robust in-process crash handler, with varying
> > results.
> > .
>
> Could GCC add a simple crash handler? maybe -fcrash-handler
I suggest -lcrash-handler. We can implement a crash handler, register it in
library initialization in libcrash-handler.so. Then we don't need to hack GCC
code.
We can borrow most of code from glibc libSegFault.so. Perhaps I'll do this work
if I can overcome my laziness.
> C++ exceptions show a few clues when there is a crash, which is helpful, eg:
>
> // g++-8 -Wall -o cpp cpp.cpp
> #include <vector>
> int main()
> {
> std::vector<int> v;
> return v.at(0);
> }
>
>
> $ ./cpp
> terminate called after throwing an instance of 'std::out_of_range'
> what(): vector::_M_range_check: __n (which is 0) >= this->size()
> (which is 0)
> Aborted
I'm not familiar with C++ exception. Maybe we can convert some instances of
unhandled signals to something like __gnu_cxx::unhandled_signal_exception, but I
believe that would require ABI changes.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2019-03-26 6:13 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 22:05 Jonny Grant
2019-03-20 4:02 ` Florian Weimer
2019-03-20 8:11 ` Jonny Grant
2019-03-25 13:23 ` Jonny Grant
2019-03-25 13:27 ` Jonathan Wakely
2019-03-25 13:56 ` Florian Weimer
2019-03-25 14:01 ` Xi Ruoyao
2019-03-25 15:47 ` Florian Weimer
2019-03-25 16:10 ` Andrew Haley
2019-03-25 16:13 ` Jonny Grant
2019-03-25 16:23 ` Jonathan Wakely
2019-03-25 18:51 ` Florian Weimer
2019-03-25 20:39 ` Jonny Grant
2019-03-26 6:50 ` Xi Ruoyao [this message]
2019-03-27 0:29 ` Jonathan Wakely
2019-03-27 21:34 ` Jonny Grant
2019-03-27 23:43 ` Jonathan Wakely
2019-03-27 23:51 ` Jonny Grant
2019-03-28 8:26 ` Xi Ruoyao
2019-03-28 11:52 ` Jonathan Wakely
2019-03-29 2:24 ` Jonny Grant
2019-03-30 17:32 ` Jonny Grant
2023-02-19 21:21 ` Jonny Grant
2023-02-19 21:34 ` Jonny Grant
2019-03-28 13:55 ` Jonathan Wakely
2019-03-28 14:39 ` Jonny Grant
2019-03-28 14:39 ` Jonathan Wakely
2019-03-25 20:28 ` Segher Boessenkool
2019-03-25 18:56 ` Segher Boessenkool
2019-03-25 22:05 ` Jonny Grant
2019-03-26 10:20 ` Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39fcf2609f20b7f6187ebf5f1f26fb01081eab5d.camel@mengyan1223.wang \
--to=xry111@mengyan1223.wang \
--cc=aph@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=gcc-help@gcc.gnu.org \
--cc=jg@jguk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).