Seeing a protected memory exception


I am seeing a protected memory exception when connecting to device.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.    at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)
   at Renci.SshNet.Common.SemaphoreLight.Wait()
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at nls.protocols.ssh.SshTerminal.InsureConnectionOpen() in d:\NLS\protocols\ssh\SshTerminal.cs:line 111
   at nls.protocols.ssh.SshTerminal.GetCommandResults(String commandText) in d:\NLS\protocols\ssh\SshTerminal.cs:line 80
   at nls.protocols.ssh.Ssh.IdentifyDevice(SshTerminal terminal) in d:\NLS\protocols\ssh\ssh.cs:line 135
   at nls.protocols.ssh.Ssh.ProcessHostData(XmlDocument sshData, Host host) in d:\NLS\protocols\ssh\ssh.cs:line 226
   at nls.lib.discoveryAgent.SingleDeviceProtocol.<>c__DisplayClass1.<ProcessHost>b__0() in d:\NLS\lib\discoveryAgent\SingleDeviceProtocol.cs:line 24
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
Closed Dec 19, 2014 at 12:52 PM by drieseng
Not an SSH.NET issue.


olegkap wrote Apr 6, 2013 at 6:59 PM

Is this behavior consistent?
Where do you run it? What environment, OS etc' ?


wrote Jul 4, 2013 at 12:43 PM

trapalas wrote Jul 4, 2013 at 12:59 PM

I have also seen this error, randomly, when trying to receive the response to a web request through a tunnel created with a ForwardedPortLocal object

My environment: Window 7 Professional 32-bits, .Net 4.0, SSH.Net vs 2013.4.7.0

Find below the code I'm running (the exception is raised in the GetResponse call). It is working well most of the times and there is not a particular request provoking the problem.
                var webReq = (HttpWebRequest)WebRequest.Create(url);
                webReq.Timeout = 15000;
                webReq.Method = "GET";
                using (var webRes = webReq.GetResponse())

trapalas wrote Jul 10, 2013 at 8:48 AM

Hhmm.. I have been debugging and testing this error and, in my case, it is not related to SSH.Net but the OS SOCK API.

So please forget my previous post...

wrote Dec 19, 2014 at 12:52 PM