Re: why does assert(0) corrupt the stack trace?

慕冬亮 <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAD-N9QX17JssrU=Eo5whDFzLLQVUUb1RidHWwqzUC3ZFY6LGJw@mail.gmail.com>
--
My best regards to you.

     No System Is Safe!
     Dongliang Mu


2017-11-05 14:54 GMT-05:00 Jan Kratochvil <[email protected]>:
> 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.
>
If I compile the program with "-O0", this problem may be solved. Yes?
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.