Running code like this under linux with gcc 9.2 (same for gcc 7.3)
#define BACKWARD_HAS_BFD 1
#include "backward.hpp"
using namespace backward;
int main() {
StackTrace st;
st.load_here(32);
Printer p;
p.print(st);
return 0;
}
causes the program to crash:
Starting program: /home/sargarass/test/stacktrace/backward-cpp-1.4/backward
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Stack trace (most recent call last):
#3 Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in
#2 Object "/home/sargarass/test/stacktrace/backward-cpp-1.4/backward", at 0x555555557cf9, in
#1 Object "/lib64/libc.so.6", at 0x7ffff786feaa, in __libc_start_main
#0 Object "/home/sargarass/test/stacktrace/backward-cpp-1.4/backward", at 0x5555555577bc, in
double free or corruption (out)
Program received signal SIGABRT, Aborted.
0x00007ffff7884f81 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff7884f81 in raise () from /lib64/libc.so.6
#1 0x00007ffff786e545 in abort () from /lib64/libc.so.6
#2 0x00007ffff78caf18 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff78d2bd8 in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff78d4b90 in _int_free () from /lib64/libc.so.6
#5 0x000055555555c616 in __gnu_cxx::new_allocator<std::__detail::_Hash_node_base*>::deallocate () at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/ext/new_allocator.h:128
#6 std::allocator_traits<std::allocator<std::__detail::_Hash_node_base*> >::deallocate () at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/bits/alloc_traits.h:470
#7 std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject>, true> > >::_M_deallocate_buckets ()
at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/bits/hashtable_policy.h:2148
#8 std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets ()
at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/bits/hashtable.h:370
#9 std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets ()
at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/bits/hashtable.h:375
#10 std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable ()
I did try the tag 1.4 and the master both of them have same issue.
Noticed that if I switch from std::unordered_map to std::map in backward.hpp header everything works just fine. Guess u are relying on std::map's property: "The insert and emplace members shall not affect the validity of iterators and references" bla bla...
Running code like this under linux with gcc 9.2 (same for gcc 7.3)
causes the program to crash:
I did try the tag 1.4 and the master both of them have same issue. Noticed that if I switch from std::unordered_map to std::map in
backward.hpp
header everything works just fine. Guess u are relying on std::map's property: "The insert and emplace members shall not affect the validity of iterators and references" bla bla...