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

roscpp: global variable name 'shutdown' will crash the ros node. #2340

Open
qpc001 opened this issue Aug 4, 2023 · 0 comments
Open

roscpp: global variable name 'shutdown' will crash the ros node. #2340

qpc001 opened this issue Aug 4, 2023 · 0 comments

Comments

@qpc001
Copy link

qpc001 commented Aug 4, 2023

When I setting a global variable bool shutdown = false; in main.cpp, and I setup a publisher to send something at /topic_xxx.

Version: ros-melodic

Env: Ubuntu18.04

Reproduction steps:

  1. rostopic echo /topic_xxx
  2. ctrl+c to closed rostopic echo
  3. the ros node which publishing /topic_xxx will crash.

code is here:

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>

bool shutdown = false;
int main(int argc, char **argv) {
    ros::init(argc, argv, "test");
    ros::NodeHandle nh;

    ros::Publisher pub_raw_map =
            nh.advertise<sensor_msgs::PointCloud2>("pointcloud_map", 1, true);
    ros::Publisher pub_probabilistic_map =
            nh.advertise<sensor_msgs::PointCloud2>("probabilistic_map", 1, true);

    sensor_msgs::PointCloud2 msg;
    pub_probabilistic_map.publish(msg);

    ros::spin();

    std::cout << "Quit..." << std::endl;
    return 0;
}

gdb log is:
image

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

1 participant