Attempted to read or write protected memory. (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hi,
I am haivng a windows service is which is making two asynchronous calls to the following function code if the two calls are made at exactly the same time it results into “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” Error. The error occurs at the lines in which I am using “WeOnlyDo.Security.Cryptography” assembly.
Can you help me out with this issue.
I am using
1. WeOnlyDo.Client.SFTP.dll - 3.2.5.64
Public Sub SftpConnect()
Sftp = New SFTP()
Sftp.Hostname = “HostName”
Sftp.Login = “UserName”
Sftp.Timeout = 0
Sftp.LicenseKey = “LicenseKey”
Dim km As New WeOnlyDo.Security.Cryptography.KeyManager()
Dim type As New WeOnlyDo.Security.Cryptography.SSHKeyTypes()
type = km.Load(Decrypt(KeyPath))
Sftp.PrivateKey = km.PrivateKey(type)
Sftp.Authentication = WeOnlyDo.Client.SFTP.Authentications.PublicKey
Sftp.Blocking = True
Sftp.Connect()
End Sub
Re: Attempted to read or write protected memory.
Hi Archit,
I tried duplicating this behaviour on my side, but was unsuccessful. Is there any chance you could send us a simple project reproducing this issue to techsupport@weonlydo.com?
Regards,
Damba
Re: Attempted to read or write protected memory.
I've got the same problem using SFTP 3.4.4.112
This is with blocking as true - if false, it hangs at the var km = new KeyManager();
stage.
This scenario is running through this code from 4 projects, at the same time.
Thanks, Paul
this.sftp = new SFTP();
this.sftp.ProgressEvent += sftp_ProgressEvent;
this.sftp.DoneEvent += sftp_DoneEvent;
this.sftp.Hostname = FtpAddress;
this.sftp.Login = FtpUserName;
this.sftp.Blocking = true;
this.sftp.Resume = true;
var km = new KeyManager();
var type = km.Load(FtpKeyLocation);
this.sftp.PrivateKey = km.PrivateKey(type);
this.sftp.Authentication = SFTP.Authentications.PublicKey;
this.sftp.Connect();
Re: Attempted to read or write protected memory.
Hi Paul,
Is there any chance you can try something like this:
http://www.weonlydo.com/code.asp?did=PublicKey-Authentication-in-SFTP&lang=CS
Let us know how it goes.
Regards,
Drazen
--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------
Re: Attempted to read or write protected memory.
Paul,
one more question - are you using multiple threads? Is it, by any chance, initializing wodKeyManager at the same moment from more than one thread? I remember about this issue I believe was recently fixed.
Kreso
Re: Attempted to read or write protected memory.
Same result I'm afraid.
Re: Attempted to read or write protected memory.
Yes, that's it. What version no. was this fixed for please?
Re: Attempted to read or write protected memory.
Hi.
Can you as a quick working put wodKeyManager initialization inside
wodKeyManager km;
lock(shared_object)
{
km = new .....
}
where shared_object is same instance for all wodKeyManager's?
Kreso
Re: Attempted to read or write protected memory.
Ah, that's done it. Thanks, Paul.
Re: Attempted to read or write protected memory.
Paul,
cool! I'm glad it's solved!
Best regards,
Kreso