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

Don't use shared_from_this in the constructor #197

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

bjsowa
Copy link
Contributor

@bjsowa bjsowa commented Jul 17, 2024

Using shared_from_this inside a constructor is dangerous:

If shared_from_this is called on an object that is not previously shared by std::shared_ptr, std::bad_weak_ptr is thrown (by the shared_ptr constructor from a default-constructed weak-this).

Right now, running scan_to_cloud_filter_chain results in std::bad_weak_ptr exception.

This PR fixes it by using a different constructor for tf2_ros::MessageFilter

@bjsowa bjsowa mentioned this pull request Jul 17, 2024
@jonbinney jonbinney self-assigned this Jul 17, 2024
Copy link
Contributor

@jonbinney jonbinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing this bug!! Can really tell people haven't been using that node and that our test coverage needs improvement :-/

@jonbinney jonbinney merged commit fb10f8b into ros-perception:ros2 Jul 22, 2024
5 checks passed
@bjsowa
Copy link
Contributor Author

bjsowa commented Jul 22, 2024

LGTM. Thanks for fixing this bug!! Can really tell people haven't been using that node and that our test coverage needs improvement :-/

This bug was introduced by #188 so I caught it just a day after. I agree that tests should have detected it though.

@bjsowa bjsowa deleted the shared-from-this-fix branch July 22, 2024 21:39
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