SshClient - thread gets blocked indefinitely, lock not released
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Using version 2020.0.0-beta1 SshClient, I was doing some load testing, and consistently encountered an issue when executing commands for an extended period of time using a single client instance (a few hours running around 1M commands).
When running the SshCommand.Execute() method, the method SemaphoreLight.Wait() waits for a lock to be released indefinitely. (SemaphoreLight.cs : Line 110)
Call stack:
System.Private.CoreLib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout, bool exitContext)
Renci.SshNet.dll!Renci.SshNet.Common.SemaphoreLight.Wait()
Renci.SshNet.dll!Renci.SshNet.Channels.ChannelSession.SendChannelOpenMessage()
Renci.SshNet.dll!Renci.SshNet.Channels.ChannelSession.Open()
Renci.SshNet.dll!Renci.SshNet.SshCommand.BeginExecute(System.AsyncCallback callback, object state)
As a workaround, disposing and recreating the SshClient object after every 10000 executions solved the problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SshCommand.Execute and its BeginExecute call path, then inspect ChannelSession.Open and SemaphoreLight.cs around line 110. Reproduce the long-running load test described in the issue using one SshClient and observe where the wait remains blocked. Done means extended command execution no longer leaves the client waiting indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100