This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: why does assert(0) corrupt the stack trace?


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


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