Bug 24379 - gdb segfault on printing atomic enum
Summary: gdb segfault on printing atomic enum
Status: RESOLVED DUPLICATE of bug 20020
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-23 15:38 UTC by hfuvre+ce22i7qsq5k3w
Modified: 2020-04-07 23:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***