Attempted to read or write protected memory. (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Archit.Aggarwal@in.ey.com @, (5525 days ago)

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

locked

Re: Attempted to read or write protected memory.

by wodDamir @, (5525 days ago) @ Archit.Aggarwal@in.ey.com

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

locked

Re: Attempted to read or write protected memory.

by Paul @, (4155 days ago) @ wodDamir

I've got the same problem using SFTP 3.4.4.112

This is with blocking as true - if false, it hangs at the [inlinecode]var km = new KeyManager();[/inlinecode] stage.

This scenario is running through this code from 4 projects, at the same time.

Thanks, Paul

[code]
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();
[/code]

locked

Re: Attempted to read or write protected memory.

by Paul @, (4155 days ago) @ Jasmine

Same result I'm afraid.

locked

Re: Attempted to read or write protected memory.

by Jasmine, (4155 days ago) @ Paul

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

locked

Re: Attempted to read or write protected memory.

by Paul @, (4155 days ago) @ Jasmine

Yes, that's it. What version no. was this fixed for please?

locked

Re: Attempted to read or write protected memory.

by Jasmine, (4155 days ago) @ Paul

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

locked

Re: Attempted to read or write protected memory.

by Paul @, (4155 days ago) @ Jasmine

Ah, that's done it. Thanks, Paul.

locked

Re: Attempted to read or write protected memory.

by Jasmine, (4155 days ago) @ Paul

Paul,

cool! I'm glad it's solved!

Best regards,
Kreso

locked