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 counting of incoming streams #89

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

marten-seemann
Copy link
Contributor

The existing code had a uint32 underflow, because we were decrementing the numIncomingStreams even if the stream was already removed from the map.

@marten-seemann marten-seemann requested review from vyzo and Stebalien June 2, 2022 10:18
session.go Outdated
@@ -850,6 +847,12 @@ func (s *Session) deleteStream(id uint32) {
return
}
s.memoryManager.ReleaseMemory(str.memory)
if s.client == (id%2 == 0) {
if s.numIncomingStreams == 0 {
panic("yamux BUG: numIncomingStream would be negative")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This panic is not caught by our panic handlers if it was caused by the application calling Close or Reset on the stream. Not really sure what the best thing to do here is. We want to surface this bug, but we can't use the normal logger for that. Every user of this library will have logging turned off, because the amount of things we log is just crazy.

Copy link
Contributor

Choose a reason for hiding this comment

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

lets just ERROR log BUG very loudly, panic is innapropriate for our our applications.

Copy link
Contributor

Choose a reason for hiding this comment

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

we should just change the logging to use go-log, it is very much forked already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to use the normal logger now, will change to go-log in a follow-up PR.

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

uh oh, lets use go-log and ERROR log loudly.

@marten-seemann
Copy link
Contributor Author

Maybe we should also remove most of the logging we have here. I haven't encountered a single case where it was useful.

@marten-seemann marten-seemann force-pushed the fix-incoming-stream-counting branch from 1e8dd76 to b8eae95 Compare June 2, 2022 10:29
@marten-seemann marten-seemann requested a review from vyzo June 2, 2022 11:03
@marten-seemann marten-seemann force-pushed the fix-incoming-stream-counting branch from b8eae95 to b1d5347 Compare June 2, 2022 13:41
@marten-seemann marten-seemann force-pushed the fix-incoming-stream-counting branch from b1d5347 to a51e116 Compare June 2, 2022 13:43
session.go Outdated
if s.numIncomingStreams == 0 {
s.logger.Printf("[ERR] yamux: numIncomingStream underflow")
}
s.numIncomingStreams--
Copy link
Contributor

Choose a reason for hiding this comment

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

else decrement, lets not make it negative.
Plus, we'll see all occurences.

@marten-seemann marten-seemann merged commit fe89b5f into master Jun 2, 2022
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.

2 participants