why does assert(0) corrupt the stack trace?
慕冬亮
mudongliangabcd@gmail.com
Sun Nov 5 20:05:00 GMT 2017
--
My best regards to you.
No System Is Safe!
Dongliang Mu
2017-11-05 14:54 GMT-05:00 Jan Kratochvil <jan.kratochvil@redhat.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.
>
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
More information about the Gdb
mailing list