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

Merged
merged 8 commits into from
Jan 7, 2025
Merged

Conversation

StalinCCCP
Copy link
Contributor

@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
Contributor 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.

@duartenfonseca
Copy link
Collaborator

@StalinCCCP could you resolve this conflict? working on merging this PR

@duartenfonseca duartenfonseca merged commit 1656f2a into COVESA:master Jan 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants