Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rosbag::Bag copy/move crash #999

Closed
racko opened this issue Feb 25, 2017 · 1 comment
Closed

rosbag::Bag copy/move crash #999

racko opened this issue Feb 25, 2017 · 1 comment

Comments

@racko
Copy link
Contributor

racko commented Feb 25, 2017

Copying (or moving in C++11 and later) rosbag::Bag causes crashes. I guess that Bags are not meant to be copied / moved. Using C++11 semantics, copying does not make sense, just as std::fstream is not copyable. Making them movable would be a benefit in C++11 but since rosbag_storage uses C++98, we cannot implement move assignment / move constructors explicitly and would have to use copy assignment / copy constructors instead, which is considered a bad design. A swap() member function should be implemented to do that. Copy assignment and copy constructor should be disabled by making them private without giving an implementation.

#include <rosbag/bag.h>
#include <std_msgs/String.h>

int main() {
    rosbag::Bag bag1("/tmp/out.bag", rosbag::bagmode::Write);
    //auto bag2 = std::move(bag1);
    auto bag2 = bag1;
    bag2.write("/data", ros::Time(0, 1), std_msgs::String());
    return 0;
}
@dirk-thomas
Copy link
Member

Addressed by #1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants