|
From: | Brock York |
Subject: | [Libunwind-devel] [Patch help]libunwind x86_64 missing actual cause frame in sigsegv handler |
Date: | Thu, 28 Feb 2019 19:29:16 +1100 |
Hello I wrote a test program (attached) to learn how to use libunwind to perform a backtrace from a sigsegv handler. To test the segfault handler the segfault was caused by calling a bad function pointer. Because of this RBP hasn't been updated as there was no function preamble to go to. This seems to screw up the back trace which ends up missing the function that called the bad function pointer as shown below in the example output. The attached patch does solve the problem for my test program but I'm not sure on what weird edge cases I could be creating. When running `make check` the test-ptrace test now fails on my machine. So I'm looking for advice about whether this could be feasible as a fix or not as I know it seems quite crazy. The following is the output from attached test program. What the output looks like from master: Handler called ip = 55987c2c4324, sp = 7ffe51cad6d0 offset = 29 name = handle_sigsegv ip = 7f5963145e00, sp = 7ffe51cad700 offset = 40 name = killpg ip = 1, sp = 7ffe51cadcb8 offset = 40 name = ip = 55987c2c43bb, sp = 7ffe51cadcc8 offset = 78 name = main ip = 7f5963132223, sp = 7ffe51cadd90 offset = f3 name = __libc_start_main ip = 55987c2c410e, sp = 7ffe51cade50 offset = 2e name = _start What it "should" look like with the missing "crash" function, this is with the patch and what a gdb backtrace shows: Handler called ip = 55ceda4c5324, sp = 7ffc963ff810 offset = 29 name = handle_sigsegv ip = 7fc00c47be00, sp = 7ffc963ff840 offset = 40 name = killpg ip = 1, sp = 7ffc963ffdd8 offset = 40 name = ip = 55ceda4c5340, sp = 7ffc963ffde0 offset = 12 name = crash ip = 55ceda4c53bb, sp = 7ffc963ffdf0 offset = 78 name = main ip = 7fc00c468223, sp = 7ffc963ffeb0 offset = f3 name = __libc_start_main ip = 55ceda4c510e, sp = 7ffc963fff70 offset = 2e name = _start To build the test program I used the following command: gcc -o unwind unwind.c -g -lunwind -lunwind-x86_64 I have been testing on: Arch Linux with gcc version 8.2.1 20181127 (GCC) x86_64 Intel i7 (laptop) Ubuntu 18.04 with gcc 7.3.0 x86_64 Intel xeon (workstation) Thank you Regards Brock
0001-Add-a-hack-to-fixup-on-a-bad-jump.patch
Description: Text Data
unwind.c
Description: Text Data
debug-with-patch.log
Description: Text Data
debug-master.log
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |