Bug 24379

Summary: gdb segfault on printing atomic enum
Product: gdb Reporter: hfuvre+ce22i7qsq5k3w
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: ssbssa
Priority: P2    
Version: 8.2   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:

Description hfuvre+ce22i7qsq5k3w 2019-03-23 15:38:41 UTC
Debugging the following program

    #include <atomic>
    
    enum class foo {ONE, TWO, THREE, FOUR, FIVE, SIX};
    
    int main(int argc, char **argv)
    {
      std::atomic<foo> x = foo::FOUR;
      std::atomic<int> y = int(foo::FOUR);
      foo z = foo::FOUR;
      return 0;
    }

(after compilation with gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC))
in gdb GNU gdb (GDB) Fedora 8.2-6.fc29:

    (gdb) break main
    Breakpoint 1 at 0x401111: file atest.cpp, line 7.
    (gdb) r
    Starting program: /home/uvb/Programming/CPPProjects/atest 
    warning: Loadable section ".note.gnu.property" outside of ELF segments
    warning: Loadable section ".note.gnu.property" outside of ELF segments
    warning: Loadable section ".note.gnu.property" outside of ELF segments

    Breakpoint 1, main (argc=1, argv=0x7fffffffd6b8) at atest.cpp:7
    7	  std::atomic<foo> x = foo::FOUR;
    (gdb) p z
    $1 = foo::ONE
    (gdb) p y
    $2 = {<std::__atomic_base<int>> = {static _S_alignment = 4, _M_i = 32767}, 
      static is_always_lock_free = true}
    (gdb) p x
    $3 = {static _S_min_alignment = 4, static _S_alignment = 4, _M_i = foo::ONE, 
    Segmentation fault (core dumped)

As can be seen, the enum can be printed, the atomic<int> can be printed, but attempting to print atomic<enum> causes gdb to segfault.
Comment 1 Hannes Domani 2020-04-07 23:51:55 UTC
Dup.

*** This bug has been marked as a duplicate of bug 20020 ***