vsomeip icon indicating copy to clipboard operation
vsomeip copied to clipboard

Fix possible dangling pointer

Open StalinCCCP opened this issue 1 year ago • 2 comments

This PR is related to https://github.com/COVESA/vsomeip/issues/695#issue-2282414325

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 avatar May 09 '24 12:05 StalinCCCP

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.

StalinCCCP avatar May 10 '24 14:05 StalinCCCP

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

duartenfonseca avatar Oct 10 '24 14:10 duartenfonseca