Bug 18157 - Segfault when debugging a program where an initializer list contains a lambda function with auto variables
Summary: Segfault when debugging a program where an initializer list contains a lambda...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: 7.8
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-24 09:17 UTC by Joe
Modified: 2015-03-24 20:08 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 Joe 2015-03-24 09:17:24 UTC
The following program:

------
#include <functional>

struct Foo {
    std::function <void(double &)> f;
    Foo (
        std::function <void(double &)> const & f_ 
    ) : f(f_) {}
};

struct Bar {
    Foo foo;
    Bar() :
        foo([](auto & num) {})
    {}
};

int main() {
    Bar bar;
}
------

segfaults gdb on startup:

$ gdb test19
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
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 test19...Segmentation fault

However, when changing the line

        foo([](auto & num) {})

to

        foo([](double & num) {})

gdb works as normal.  In case it helps:

GNU gdb (Gentoo 7.7.1 p1) 7.7.1
gcc version 4.9.2 (Gentoo 4.9.2 p1.0, pie-0.6.1)
Comment 1 Keith Seitz 2015-03-24 20:08:09 UTC
I've verified that this is another libiberty demangler crashing bug.  It is also fixed in GDB 7.8+.

If you'd like a patch, look at commits 91662bad2, fd259167d, 9548bbede, and 53f94b92e (all in libiberty).

It might be possible to toss together something relatively easily by simply grabbing a recent copy of libiberty/cp-demangle.[ch].

Otherwise, the easiest thing to do is simply upgrade to 7.8 or 7.9.