3 ms·
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 t
by DaveFlater 4y ago
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 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 https://doi.org/10.6028/NIST.TN.1790
- zznzz 4y agoI 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.
- DaveFlater 4y agoAFAIK, 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
- sitkack 4y agoThat 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.