Bug 16845 - GDB crashs when debugging a simple example of rvalues
Summary: GDB crashs when debugging a simple example of rvalues
Status: RESOLVED DUPLICATE of bug 16752
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-15 21:30 UTC by Edward Bart
Modified: 2014-04-17 10:05 UTC (History)
2 users (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 Edward Bart 2014-04-15 21:30:33 UTC
GDB is crashing when trying to debug a simple binary generated by the code provided below. However it runs fine when compiling with optimization active.

$ g++ --version
g++ (GCC) 4.8.2 20140206 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ -std=c++11 bug.cpp -O0 -o bug && gdb ./bug
GNU gdb (GDB) 7.7
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-unknown-linux-gnu".
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 ./bug...Segmentation fault (core dumped)


$ g++ -std=c++11 bug.cpp -O1 -o bug && gdb ./bug
GNU gdb (GDB) 7.7
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-unknown-linux-gnu".
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 ./bug...(no debugging symbols found)...done.
(gdb) 


Test case file:

#include <vector>
#include <functional>
#include <memory>

std::vector<std::function<void()>> tasks;

template<class F>
void post(F&& task) {
    typedef typename std::remove_reference<F>::type _F;
    std::shared_ptr<_F> taskPtr(new _F(std::forward<F>(task)));
    tasks.push_back([taskPtr] { (*taskPtr)(); });
}

void add_task() {
    std::function<void()> action;
    post(std::move(action));
}

int main()
{
    return 0;
}
Comment 1 Keith Seitz 2014-04-15 21:45:08 UTC
I have verified that this is a dup of the listed libiberty demangler bug.

*** This bug has been marked as a duplicate of bug 16752 ***
Comment 2 Keith Seitz 2014-04-15 21:47:21 UTC
I should add: the symbol which causes problems this time is:

_ZNSt9_Any_data9_M_accessIPZ4postISt8functionIFvvEEEvOT_EUlvE_EERS5_v
Comment 3 Gary Benson 2014-04-17 10:05:44 UTC
Edward, thanks for the minimal testcase, that's actually a big help.