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 mismatched channel owners #4750

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

pwojcikdev
Copy link
Contributor

@pwojcikdev pwojcikdev commented Oct 8, 2024

There were a few testcases where messages were passed with channels belonging to other nodes, which was causing strange lifetime issues. This adds asserts to ensure this won't happen.

@pwojcikdev pwojcikdev changed the title Fix Mismatched channel owners Fix mismatched channel owners Oct 8, 2024
@qwahzi qwahzi added this to the V28 milestone Oct 10, 2024
@@ -520,6 +520,8 @@ void nano::node::keepalive (std::string const & address_a, uint16_t port_a)

void nano::node::inbound (const nano::message & message, const std::shared_ptr<nano::transport::channel> & channel)
{
debug_assert (channel->owner () == shared_from_this ()); // This node should be the channel owner
Copy link
Contributor

Choose a reason for hiding this comment

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

We could have owner return a naked pointer and compare against 'this' since we're not intending to manage lifetime. I'm fine with keeping this though since it's just test code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if it was compiled in release then this should be done, but I try to avoid naked pointers unless absolutely necessary to avoid shooting myself in the foot accidentally.

@pwojcikdev pwojcikdev merged commit 9ff68c1 into nanocurrency:develop Oct 16, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged / V28.0
Development

Successfully merging this pull request may close these issues.

3 participants