ObjectDisposedException once in a while
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
We are seeing ObjectDisposedExceptions once in a while:
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.ObjectDisposedException
bei System.Net.Sockets.Socket.AcceptAsync(System.Net.Sockets.SocketAsyncEventArgs)
bei Renci.SshNet.ForwardedPortLocal.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
bei Renci.SshNet.ForwardedPortLocal.AcceptCompleted(System.Object, System.Net.Sockets.SocketAsyncEventArgs)
bei System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs)
bei System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
bei System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
bei System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
bei System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)
bei System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
bei System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
These exceptions should be prevented in SSH.Net by catching the exception and ignoring it if the status is Stopped or Stopping. The status is set to Stopping before the _listener is disposed.
However, the status is checked for Stopped twice, instead of Stopping or Stopped. This is a simple oversight.
Same thing in ForwardedPortDynamic.NET.cs
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 in src/Renci.SshNet/ForwardedPortLocal.NET.cs at StartAccept and inspect the status check around listener disposal, then compare the corresponding logic in ForwardedPortDynamic.NET.cs. Reproduce or reason through an accept completion during shutdown; done means shutdown-time ObjectDisposedException instances are prevented in both forwarded-port implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100