by userbinator · 3y ago · 0 comments
The thing is that DWARF unwinding (the only userspace option that doesn’t use frame pointers) is really unreliable. In fact it has such serious problems that it’s not that usable at all.
The real solution to things like this is to improve the debugging information so that return addresses can be tracked more accurately, but no one seems willing to do that work. It reminds me of encountering "value optimised out" when I can clearly see where the value is if I inspect the Asm.
Explicit constant frame pointers are almost an anachronism from an era when compilers were far worse at code generation. It seemed like a good idea at the time because it made compilers simpler, and of course on 16-bit x86 bp was the only other register that defaulted to the stack segment and [sp+nn] didn't exist. Those points are not really relevant anymore with 32-bit and 64-bit x86 using a flat memory model. Sometimes the extra byte needed for esp/rsp-relative access is worse, sometimes the extra register consumed by ebp/rbp-relative access is worse. It's really something that needs to be decided case-by-case like a intelligent Asm programmer would.
As someone who’s excited about Fedora’s change, I agree. But while waiting for that to happen, I want to have a good debug/tracing experience, which currently only frame pointers can provide.
What's the rush? We've lived without adequate unwinding this long. We can afford to take a little bit more time and do it right.
Is the "real solution" a case of letting "the perfect" get in the way of "good enough" (sic)?
In fact it might be the exact opposite. We have very complicated mechanisms that try to keep track of every possible optimization. Maybe that effort is getting in the way of a solution that slightly limits frame pointer optimization but easily figures out the value in all situations.
So because the "perfect" mechanism is having implementation problems, and nobody has tried to make the "good" mechanism, we're stuck with the very mediocre "reserve a register".
Can you share an example of when that happens?
This is likely wrong. The kernel does not have a DWARF unwinder. He's probably just desymbolizing a poor stack trace taken by the kernel chasing ebps, not unwinding it with DWARF.