Fix segfault when camera dispay closed. Closes #1372. #1393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Actually segfault happens in
CBQueueCallback::call
method while callingfilter_->signalMessage(event_)
:CBQueueCallback
object is constructed inMessageFilter::messageReady
method:and it holds
MessageFilter
pointer as argument:At call time
filter_
object is already destroyed inrviz/src/rviz/image/image_display_base.cpp
Lines 204 to 208 in 57325fa
CBQueueCallback
object is called fromcallback_queue_
:which actually the same as
update_nh_.getCallbackQueue()
:tf_filter
constructed fromupdate_nh_
:rviz/src/rviz/image/image_display_base.cpp
Lines 179 to 185 in 57325fa
MessageFilter
ctor initcallback_queue_
ascallback_queue_(nh.getCallbackQueue())
:This all looks like a thread sync problem, but I wasn't able to track it.
I am unsure if it is bug in TF2 message filter, so I suggest to use less invasive method and fix this bug in RViz code by removing callback by id before message_filter reset.