Invalid program counters and unwinding

John Reiser jreiser@bitwagon.com
Tue Jun 26 13:39:00 GMT 2018


On 06/26/2018, Jakub Jelinek wrote:

> The usual ways to get bogus PCs in the frames is:
> 1) stack corruption
> 2) setcontext/swapcontext with uninitialized or corrupted ucontext_t
> 3) bogus unwind info (compiler or linker etc. bug)
> 
> At least for unwinding, I think we don't and shouldn't care, we assume only
> valid programs.

That assumption is not reliable in practice.  About once per year I find
a totally bogus PC value while unwinding, such as:

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66874
     RFE: x86_64_fallback_frame_state more robust

   https://sourceware.org/bugzilla/show_bug.cgi?id=18635
     stdlib/tst-makecontext fails on ix86

At least *some* run-time effort should be made to protect against SIGSEGV
when a purported PC is 0, or otherwise obviously bogus.



More information about the Binutils mailing list