From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: 慕冬亮 <mudongliangabcd@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: why does assert(0) corrupt the stack trace?
Date: Sun, 05 Nov 2017 19:54:00 -0000 [thread overview]
Message-ID: <20171105195410.GA29185@host1.jankratochvil.net> (raw)
In-Reply-To: <CAD-N9QVbDJNJXrnsS3PNTvRXvvUK=pB6f+Gpj4WGTSjMoYR9pg@mail.gmail.com>
On Sun, 05 Nov 2017 20:13:20 +0100, 慕冬亮 wrote:
> I have a question about debugging assert in gdb. When one program
> crash at one assert statement, the stack trace shown in the gdb is
> corrupted. Is it normal?
It was happening in the past as when assert() detects a failure it calls
abort() which does never return - using GCC attribute noreturn. Then GCC
optimizer does not save enough registers to make the backtrace possible
because the code will just abort anyway, the code does not need to know where
to return.
It was some intermediate development phase where such optimization was created
and before an exception has been made to make the backtracing by debuggers
possible.
Sorry for not looking up the Bugs/commits.
As usual you should update your compiler + debugger to latest versions.
Jan
next prev parent reply other threads:[~2017-11-05 19:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-05 19:13 慕冬亮
2017-11-05 19:46 ` Paul Smith
2017-11-05 19:54 ` Jan Kratochvil [this message]
2017-11-05 20:05 ` 慕冬亮
2017-11-05 20:10 ` Jan Kratochvil
2017-11-05 22:01 ` Duane Ellis
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=20171105195410.GA29185@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb@sourceware.org \
--cc=mudongliangabcd@gmail.com \
/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