You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been working at rolling out a go-based ssh server to replace some old infra and we noticed that after handling a few million connections, the memory usage seems to go up from about 6MB to 30MB over the course of a day. This obviously isn't a very large leak, but it's definitely noticeable over a long period of time.
After investigating, I think we've narrowed it down to the fact that the only function which closes the channel's request channel (*channel.close()) is never called if a connection dies early. It is only closed if the channel gets a msgChannelClose in *channel.handlePacket.
This leaves any server implementation using ssh.DiscardRequests open to a goroutine leak because the channel that function is ranging over never gets closed and therefore the goroutine never exits even when the underlying connection (and in extension, ssh-channel) is closed.
I don't have a simple example yet, as writing ssh server implementation is not simple and distilling a bug down to a reproducible case isn't easy, but I'll update this when I have one.
What did you expect to see?
No memory leak.
What did you see instead?
A very small memory leak.
Additional notes:
*channel.Close never actually calls *channel.close. It simply sends a msgChannelClose.
The text was updated successfully, but these errors were encountered:
go version
)?go version go1.6.2 linux/amd64
go env
)?We've been working at rolling out a go-based ssh server to replace some old infra and we noticed that after handling a few million connections, the memory usage seems to go up from about 6MB to 30MB over the course of a day. This obviously isn't a very large leak, but it's definitely noticeable over a long period of time.
After investigating, I think we've narrowed it down to the fact that the only function which closes the channel's request channel (
*channel.close()
) is never called if a connection dies early. It is only closed if the channel gets amsgChannelClose
in*channel.handlePacket
.This leaves any server implementation using
ssh.DiscardRequests
open to a goroutine leak because the channel that function is ranging over never gets closed and therefore the goroutine never exits even when the underlying connection (and in extension, ssh-channel) is closed.I don't have a simple example yet, as writing ssh server implementation is not simple and distilling a bug down to a reproducible case isn't easy, but I'll update this when I have one.
No memory leak.
A very small memory leak.
Additional notes:
*channel.Close
never actually calls*channel.close
. It simply sends amsgChannelClose
.The text was updated successfully, but these errors were encountered: