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

Avoid uncatchable exception in bagthread #2139

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions tools/rosbag/src/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,55 @@ int Recorder::run() {
boost::thread record_thread;
if (options_.snapshot)
{
record_thread = boost::thread(boost::bind(&Recorder::doRecordSnapshotter, this));
record_thread = boost::thread([this]() {
try
{
this->doRecordSnapshotter();
}
catch (const rosbag::BagException& ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 1;
}
catch (const std::exception& ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 2;
}
catch (...)
{
ROS_ERROR_STREAM("Unknown exception thrown while recording bag, exiting.");
exit_code_ = 3;
}
});

// Subscribe to the snapshot trigger
trigger_sub = nh.subscribe<std_msgs::Empty>("snapshot_trigger", 100, boost::bind(&Recorder::snapshotTrigger, this, _1));
}
else
record_thread = boost::thread(boost::bind(&Recorder::doRecord, this));


{
record_thread = boost::thread([this]() {
try
{
this->doRecord();
}
catch (const rosbag::BagException& ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 1;
}
catch (const std::exception& ex)
{
ROS_ERROR_STREAM(ex.what());
exit_code_ = 2;
}
catch (...)
{
ROS_ERROR_STREAM("Unknown exception thrown while recording bag, exiting.");
exit_code_ = 3;
}
});
}

ros::Timer check_master_timer;
if (options_.record_all || options_.regex || (options_.node != std::string("")))
Expand Down