I am attempting to store some `rosbag::Bag`s in a `std::vector`, but calling:
std::vector bags;
bags.push_back(rosbag::Bag());
results in the following segfault:
#0 0x00007ffff62c7c6d in rosbag::ChunkedFile::swap(rosbag::ChunkedFile&) () from /opt/ros/melodic/lib/librosbag_storage.so
#1 0x00007ffff62a7014 in rosbag::Bag::swap(rosbag::Bag&) () from /opt/ros/melodic/lib/librosbag_storage.so
#2 0x00007ffff62aef75 in rosbag::Bag::Bag(rosbag::Bag&&) () from /opt/ros/melodic/lib/librosbag_storage.so
#3 0x00007ffff7bc0991 in __gnu_cxx::new_allocator::construct (this=0x677608, __p=0x687820, __args=...)
at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/ext/new_allocator.h:136
#4 0x00007ffff7bc05cd in std::allocator_traits>::construct (__a=..., __p=0x687820, __args=...)
at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/alloc_traits.h:475
#5 0x00007ffff7bc06a5 in std::vector>::_M_realloc_insert (this=0x677608, __position=non-dereferenceable iterator for std::vector, __args=...)
at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/vector.tcc:415
#6 0x00007ffff7bc0581 in std::vector>::emplace_back (this=0x677608, __args=...)
at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/vector.tcc:105
#7 0x00007ffff7bbcd40 in std::vector>::push_back (this=0x677608, __x=...)
at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_vector.h:954
I have tried to use `std::move` in the `push_back` from a `Bag` object allocated on the stack, but the result is the same (segfault).
How can I correctly create a `std::vector` of Bag objects?
I am using ROS Melodic on Ubuntu 18.04 on an x86-64 CPU
↧