ObjectDisposedException while connecting ssh
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
sometimes I get an error while using ssh connection, it is the cause of crashed app, with the following log messages:
2019-09-16 10:04:22.710 OneLink.iOS[307:17928]
Unhandled Exception:
System.ObjectDisposedException: Safe handle has been closed
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef (System.Boolean& success) [0x0001c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:125
at System.Threading.NativeEventCalls.SetEvent (Microsoft.Win32.SafeHandles.SafeWaitHandle handle) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/corlib/System.Threading/NativeEventCalls.cs:61
at System.Threading.EventWaitHandle.Set () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/eventwaithandle.cs:319
at Renci.SshNet.Abstractions.SocketAbstraction.ConnectCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) [0x0000f] in :0
==========================================
I checked your codes, and I think that the problem in the function
public static Socket Connect(IPEndPoint remoteEndpoint, TimeSpan connectTimeout)
in file src/Renci.SshNet/Abstractions/SocketAbstraction.cs.
Maybe we must remove Completed callback function before disposing of ManualResetEvent.
Can you help me to check this issue?
Thanks so much!
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/Abstractions/SocketAbstraction.cs at Connect(IPEndPoint remoteEndpoint, TimeSpan connectTimeout). Trace the SocketAsyncEventArgs.Completed callback and the ManualResetEvent lifetime around timeout and disposal. Done means the reported ObjectDisposedException no longer occurs while connecting over SSH, including when the connection completes near disposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100