Skip to content

Assert if soref() is called on an already-released socket.#703

Open
JonathanLennox wants to merge 2 commits intosctplab:masterfrom
JonathanLennox:dont-soref-freed-socket
Open

Assert if soref() is called on an already-released socket.#703
JonathanLennox wants to merge 2 commits intosctplab:masterfrom
JonathanLennox:dont-soref-freed-socket

Conversation

@JonathanLennox
Copy link
Copy Markdown
Contributor

No description provided.

@JonathanLennox JonathanLennox force-pushed the dont-soref-freed-socket branch from e719a63 to 5d461ee Compare April 1, 2024 18:22
KASSERT((so)->so_count > 0, ("sorele")); \
if (--(so)->so_count == 0) \
if (--(so)->so_count == 0) { \
(so)->so_count = -1; \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we actually do this, sofree() will return early, since so->so_count != 0 would be true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right; see my follow-up commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please fix merge conflict.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've rebased it.

@JonathanLennox
Copy link
Copy Markdown
Contributor Author

The reason for this PR is to try to track down the issue I reported in #676 -- the garbage value in so_count implies that the memory has been re-used, for which the most likely explanation is that the socket has been freed.

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.

3 participants