Closed lprobsth closed 1 year ago
In the constructor, it looks like you are allocating a new Subscriber and assigning it to a local Subscriber variable called g_subscr_ptr
, rather than to the global Subscriber at the top of the snippet. Is that just a copy/paste error in your example? Calling shutdown
on an invalid pointer could certainly cause a segfault.
I'm really sorry - the shutdown function of the Subscriber works as expected.
My code example was an extract from a much bigger program - the pointer where I stored the Subscriber was sometimes not initialized and then pointed into random locations. I did check if the pointer is Null - but this check was not sufficient in that case. So my program tried to unsubscribe with a non existent Subscriber which led to the segfault.
I'm using ROS noetic and building a universal serialization program for bridging our custom message transport system with ROS. For converting ROS messages to our transport system, I'm using a universal subscriber with the help of RosMsgParser. Nodes can add or remove bridges for certain topics during runtime. The creation of new subcribers during runtime works fine and the bridge also works as expected.
When I try to delete Subscribers during removal of a bridge connection, I get a segmentation fault.
The following code shows a minimal example.
Problems I have in mind right now:
Did anybody use the shutdown function of Subscriber or run into a similar problem? Is there anything more I could provide (e.g. building ros_comm with debug symbols)?