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

Fix possible dangling pointer #698

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

StalinCCCP
Copy link

@StalinCCCP StalinCCCP commented May 9, 2024

This PR is related to #695 (comment)

Considering std::bind would make T&& a T(rvalue to lvalue), and that copying shared_pointer will automatically add a reference count and hold its ownership, I changed the first parameter of accept_cbk() from const connection::ptr& to connection::ptr. This change guarantees no dangling pointer would be possible.

@StalinCCCP
Copy link
Author

StalinCCCP commented May 10, 2024

To examine if dangling pointer could happen, just add a logging output(VSOMEIP_DEBUG, std::cerr, etc.) to ~connection() and accept_cbk(). You might find that ~connection() is called earlier than accept_cbk(), which indicates the connection object has been destructed already before accept_cbk() being called.

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.

None yet

1 participant