https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114116

--- Comment #14 from Lukas Grätz <lukas.gra...@tu-darmstadt.de> ---
(In reply to Jakub Jelinek from comment #2)
> Created attachment 57545 [details]
> gcc14-pr114116.patch
> 
> This seems to fix it, so far tested just on the small testcase, back to the
> expected backtrace there.

As I said in PR 38534, comment [1], the rsp could be saved to rbp due to an
unknown-sized stack-frame:

        movq    %rsp, %rbp
        .cfi_def_cfa_register 6

Therefore, if we want the backtrace in such situations, we would need to save
rbp, too, as your patch does. The patch might even not be enough, if there is
the possibility that we could .cfi_def_cfa_register with a register other than
rbp/6. In that case, the patch can be ignored and it is left to disable the
optimization by default, as you already suggested, I think you already have a
patch for that.

H.J. Lu's patch to emit .cfi_undefined is needed in any case. Only that both
patches are currently incompatible.


There also seems to be a bug in libgcc/unwind-dw2.c:249, causing a SEGV when
register values are unavailable due to .cfi_undefined. This is already known,
as the comment there suggests. This happens during a call to glibc's
backtrace(), even though the registers are not needed for the backtrace (in
that case, gdb's backtrace is fine, glibc's backtrace crashes in libgcc). It
should be possible to print best-effort-traces without crashing, in fact,
calling backtrace() should never lead to a crash. Bug 103510 might be related
and this should be fixed independently.

Thanks for the work putting in this and I am sorry for the mess on my side!

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38534#c45

Reply via email to