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

--- Comment #3 from Timo Teräs <timo.teras at iki dot fi> ---
$ cat a.cpp <<EOF
#include <iostream>

int foo()
{
     throw "Foo!";
}

int main ()
{
   try {
     foo();
   }catch (const char* msg) {
     std::cerr << msg << std::endl;
   }
   return 0;
}
EOF

$ gdb a
GNU gdb (GDB) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a...done.
(gdb) run
Starting program: a 

Program received signal SIGSEGV, Segmentation fault.
0x000003ffb7db9780 in _Unwind_GetGR () from /usr/lib/libgcc_s.so.1
(gdb) where
#0  0x000003ffb7db9780 in _Unwind_GetGR () from /usr/lib/libgcc_s.so.1
#1  0x000003ffb7dba938 in ?? () from /usr/lib/libgcc_s.so.1
#2  0x000003ffb7dbab88 in ?? () from /usr/lib/libgcc_s.so.1
#3  0x000003ffb7dbaed4 in _Unwind_RaiseException () from /usr/lib/libgcc_s.so.1
#4  0x000003ffb7e74d28 in __cxa_throw () from /usr/lib/libstdc++.so.6
#5  0x000002aaaaaa0e34 in foo() ()
#6  0x000002aaaaaa0e44 in main ()
(gdb) info registers
x0             0x8      8
x1             0x1d     29
x2             0x0      0
x3             0x4000000000000000       4611686018427387904
x4             0x0      0
x5             0x0      0
x6             0x3b0    944
x7             0x3ffffffed40    4398046506304
x8             0x2aaaaaa0fa8    2932030967720
x9             0x3ffffffecc0    4398046506176
x10            0xa42a4  672420
x11            0xa42a4  672420
x12            0xb66b4978       3060484472
x13            0x18     24
x14            0x100000000000000        72057594037927936
x15            0xb66b4978       3060484472
x16            0x3ffb7dcee90    4396836253328
x17            0x3ffb7f7a528    4396838004008
x18            0x2aaaaaa06c9    2932030965449
x19            0x3fffffff1e0    4398046507488
x20            0x3fffffff1e0    4398046507488
x21            0x3ffffffe980    4398046505344
x22            0x3fffffff5a0    4398046508448
x23            0x190    400
x24            0x3ffb8005000    4396838572032
x25            0x3fffffff5a0    4398046508448
x26            0x3ffb8003000    4396838563840
x27            0x0      0
x28            0x0      0
x29            0x3fffffffc50    4398046510160
x30            0x3ffb7dba938    4396836170040
sp             0x3ffffffe910    0x3ffffffe910
pc             0x3ffb7db9780    0x3ffb7db9780 <_Unwind_GetGR+72>
cpsr           0x60000000       1610612736
fpsr           0x0      0
fpcr           0x0      0
(gdb) disas
Dump of assembler code for function _Unwind_GetGR:
   0x000003ffb7db9738 <+0>:     cmp     w1, #0x61
   0x000003ffb7db973c <+4>:     b.le    0x3ffb7db9748 <_Unwind_GetGR+16>
   0x000003ffb7db9740 <+8>:     str     x30, [sp,#-16]!
   0x000003ffb7db9744 <+12>:    bl      0x3ffb7db2670 <abort@plt>
   0x000003ffb7db9748 <+16>:    ldr     x3, [x0,#832]
   0x000003ffb7db974c <+20>:    sxtw    x1, w1
   0x000003ffb7db9750 <+24>:    ldr     x2, [x0,x1,lsl #3]
   0x000003ffb7db9754 <+28>:    tbz     x3, #62, 0x3ffb7db976c
<_Unwind_GetGR+52>
   0x000003ffb7db9758 <+32>:    add     x0, x0, x1
   0x000003ffb7db975c <+36>:    ldrb    w0, [x0,#856]
   0x000003ffb7db9760 <+40>:    cbz     w0, 0x3ffb7db976c <_Unwind_GetGR+52>
   0x000003ffb7db9764 <+44>:    mov     x0, x2
   0x000003ffb7db9768 <+48>:    ret
   0x000003ffb7db976c <+52>:    adrp    x0, 0x3ffb7dcf000
   0x000003ffb7db9770 <+56>:    add     x0, x0, #0x70
   0x000003ffb7db9774 <+60>:    ldrb    w0, [x0,x1]
   0x000003ffb7db9778 <+64>:    cmp     w0, #0x8
   0x000003ffb7db977c <+68>:    b.ne    0x3ffb7db9740 <_Unwind_GetGR+8>
=> 0x000003ffb7db9780 <+72>:    ldr     x0, [x2]
   0x000003ffb7db9784 <+76>:    b       0x3ffb7db9768 <_Unwind_GetGR+48>
End of assembler dump.
(gdb) quit
A debugging session is active.

        Inferior 1 [process 13752] will be killed.


This got fixed when removing -fomit-frame-pointer from libgcc_s build.

Reply via email to