paramiko / paramiko/paramiko

Potential memory leak in Transport.start_server

Open
#640 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs investigation
Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

I'm not sure if this is a leak or an ambiguity on how to use the async version of Transport.start_sever with event being passed, and how to synchronize/accept the client on the server transport.

See https://gist.github.com/mdellavo/9dd98e6223c6f815ad45 -- this version passes an event to Transport.start_server and does not call Transport.accept(), after the transport disconnects, we see that there is an unaccepted Channel in Transport.server_accepts that is now disconnected. Due to the circular reference held between Channel and Transport , this causes a memory leak.

We've also seen in our production code that calling Transport.accept() will return "channel closed" on the client, though this may be unrelated.

See https://gist.github.com/mdellavo/d349cbc9ffc3b30c1862 -- this version does uses the synchronous version (no accept), calls Transport.accept() and functions normally.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the async Transport.start_server path described in the first gist, then inspect Transport.server_accepts, Transport.accept(), and the Channel/Transport references during disconnect. Reproduce the unaccepted-channel case and compare it with the synchronous example; done means the retention behavior and accept semantics are resolved and covered by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.