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

Crash if throwing buffer too short exception #8

Open
mortenfyhn opened this issue Jun 3, 2019 · 2 comments
Open

Crash if throwing buffer too short exception #8

mortenfyhn opened this issue Jun 3, 2019 · 2 comments

Comments

@mortenfyhn
Copy link

Hey guys, we noticed that the broker crashes because of an unhandled exception if IMC::BufferTooShort gets thown. The TCP buffers in TcpLink.hpp are 1024 bytes long, and messages with a rawdata field (vector of char in C++) can easily exceed this. That throws IMC::BufferTooShort, which is not caught, so the broker crashes.

Here's a minimal working example node implementation that triggers the crash:

#include <ros/ros.h>
#include <ros_imc_broker/ImcTypes.hpp>

int main(int argc, char** argv)
{
    ros::init(argc, argv, "broker_bug");
    ros::NodeHandle nh;
    ros::Publisher pub =
        nh.advertise<IMC::UASimulation>("/IMC/Out/UASimulation", 1);

    ros::Rate rate(1);
    while (ros::ok())
    {
        IMC::UASimulation msg;
        msg.data = std::vector<char>(1000);
        pub.publish(msg);
    }
}

and I'll upload a zip with the whole MWE ros package, with CMakeLists, launch file, etc:

broker_bug.zip

The desired behaviour is I suppose to print an error message or something such and carry on.

@josebraga
Copy link
Contributor

Hi Morten, is it possible you have you a PR ready to go?

@mortenfyhn
Copy link
Author

I've only made a "fix the symptom not the problem" solution by making the buffer larger by now, but I can fix a proper PR soon.

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