News for hackers. Stuff that matters.
Re:Frame pointers vs. DWARF – my verdict by DaveFlater on Wednesday February 15, 2023 @08:51AM (#34803759)
Uh... [Begin flashback] 2012: A change made in GCC 4.7 allowed optimization to reschedule and defer the push of the frame pointer that previously occurred in the function prologue whenever frame pointers were enabled. When binaries are profiled using frame pointers, incorrect call chains are derived whenever a sample is taken between the top of the function and the instruction that pushes the frame pointer. I complained, but got an immediate WONTFIX: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55667

So did they fix that eventually or is everyone just oblivious?

How I found the problem in 2012: Configuration of profiling tools for C/C++ applications under 64-bit Linux https://doi.org/10.6028/NIST.TN.1790

Re:Frame pointers vs. DWARF – my verdict by zznzz on Wednesday February 15, 2023 @10:25AM (#34805014)
I cannot comment on whether “everyone” is oblivious but yes, this is still the case - frame pointer based unwinding sometimes skips the caller when the IP is sampled before the callee sets up a frame.

This is also common for samples in leaf functions.

compiler & tool chain folks tend to think (quite justifiably imo) that this and similar stuff is fine because dwarf allows reconstructing everything perfectly. The problem is just that the user experience of dwarf-based unwinding is poor, because the only implemented method in Linux is sampling the contents of the stack and doing the unwind in post processing.

Re:Frame pointers vs. DWARF – my verdict by DaveFlater on Wednesday February 15, 2023 @10:53AM (#34805455)
AFAIK, the optimization undermined the only use case that -fno-omit-frame-pointer actually had on x86_64. Is there a real use case that benefitted from allowing the frame pointer push to wander? Why why why
Re:Frame pointers vs. DWARF – my verdict by sitkack on Wednesday February 15, 2023 @05:31PM (#34811749)
That is too bad, it does mention `-fno-schedule-insns2` in the comments. I'll have to see how well that works in practice.

Having high quality low cost stack straces is important for continuous profiling. ref Knuth.