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

Changed to CallbackInterfacePtr (shared_ptr) #2

Open
wants to merge 2 commits into
base: indigo-devel
Choose a base branch
from

Conversation

rethink-imcmahon
Copy link
Collaborator

  • removed reference to info.callback
  • removed the weak_ptr, CallbackInterfaceWPtr
    The ROS Timers were not receiving callbacks with the weak_ptr callback reference.

IanTheEngineer and others added 2 commits August 25, 2015 14:51
This issue manifested with periodic coredumps in the onRetryTimer()
callback in transport_publisher_link.cpp. These crashes were infrequent,
and extremely difficult to reproduce. They appeared to happen when
many Subscriptions were being destroyed, which made it likely to be
a destruction scheduling anomaly.

The underlying issue was a copy of CallbackInfo being created in
callback_queue.cpp. By creating a copy of this object, its shared
pointer reference count for CallbackInterface was incremented,
preventing destruction of the CallbackInterface by an external thread,
even if all of the other Subscription resources had been destroyed.
This lead to partial execution of the onRetryTimer callback, until
it attempted to access the destroyed Subscription parent, causing an
invalid memory access, and coredump. This issue only occurs if
the Subscription is destroyed while the callback_queue is blocked by
attempting to lock the boost::shared_lock<boost::shared_mutex> rw_lock()
which would make this a time-dependant thread scheduling issue.

To remedy the the invalid callback, a reference to the CallbackInfo
object in Thread Local Storage (tls) is made rather than a copy. This
prevents the CallbackInterface shared pointer reference count from being
incremented (since only the reference is taken). To access the callback
for execution, a weak pointer is made from the CallbackInterface. Then
after the mutex lock is acquired, the weak pointer is used to create a
shared pointer for callback execution. If the weak pointer fails to
return a shared pointer, the CallbackInterface has been destroyed.
In that case, the callback is Invalid and execution is prevented.
- removed reference to `info.callback`
- removed the weak_ptr, CallbackInterfaceWPtr
The ROS Timers were not receiving callbacks with the weak_ptr callback reference.
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

Successfully merging this pull request may close these issues.

2 participants