2
Vote

Seeing a protected memory exception

description

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()

comments

olegkap wrote Apr 6, 2013 at 5:59 PM

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

Thanks,
Oleg

trapalas wrote Jul 4, 2013 at 11:59 AM

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 7: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...
Thanks