[libcxx-commits] [PATCH] D114818: [libunwind] Fix unwind_leaffunction test
Leonard Chan via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 30 15:14:06 PST 2021
leonardchan added a comment.
In D114818#3162689 <https://reviews.llvm.org/D114818#3162689>, @ldionne wrote:
> In D114818#3162675 <https://reviews.llvm.org/D114818#3162675>, @vvereschaka wrote:
>
>> Hi @ldionne, @leonardchan
>>
>> I ran these changes on Linux (Ubuntu 18.04)/Aarch64 board. The test gets failed because of missed 'main':
>>
>> ubuntu at jetson8:/tmp$ ./t.tmp.exe
>> info.dli_sname: _Z14signal_handleri
>> info.dli_sname: __kernel_rt_sigreturn
>> info.dli_sname: _Z18crashing_leaf_funcv
>> info.dli_sname: __libc_start_main
This is what I'm running into also.
> Do we need to apply `__attribute__((noinline))` to `main`? Can you try that out and let me know if that helps?
Locally `__attribute__((noinline))` on main doesn't seem to change anything for me. I checked the unwind info and made sure it's emitted correctly. The CIE for `crashing_leaf_func` is
[0x202918] CIE length=20
version: 1
augmentation: zR
code_alignment_factor: 1
data_alignment_factor: -4
return_address_register: 30
Program:
DW_CFA_def_cfa: reg31 +0
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
and it's FDE is
[0x202970] FDE length=20 cie=[0x202918]
initial_location: 0x2134ac
address_range: 0x8 (end : 0x2134b4)
Program:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
DW_CFA_nop:
which I think just indicates that libunwind should use x30 for finding the return address. If I stop right before the `__builtin_trap()`, it looks like x30 points back into main (right after the call to `crashing_leaf_func`):
x30 0x2134fc 2176252
...
(gdb) info symbol 0x2134fc
main + 60 in section .text of /home/leonardchan/llvm-monorepo/llvm-build-1-master-fuchsia-toolchain/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/Output/unwind_leaffunction.pass.cpp.dir/t.tmp.exe
...
Leonard Chan, 9 min
(gdb) disas 0x2134fc
Dump of assembler code for function main:
...
0x00000000002134f8 <+56>: bl 0x2134ac <_Z18crashing_leaf_funcv>
0x00000000002134fc <+60>: mov w0, #0xfffffffe // #-2
...
One thing I also noticed is that if we add another function call, something like:
void crashing_leaf_func() {
__builtin_trap();
}
void func() {
crashing_leaf_func();
}
int main() {
signal(SIGTRAP, signal_handler);
signal(SIGILL, signal_handler);
func();
return 2;
}
Then the test passes, but it looks like unwinder skips past `func` (it jumps from `_Z18crashing_leaf_funcv` to `main`). Perhaps all this hints at an underlying issue in libunwind?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114818/new/
https://reviews.llvm.org/D114818
More information about the libcxx-commits
mailing list