Attempted to read or write protected memory. - WeOnlyDo Discussion board

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

by Archit.Aggarwal@in.ey.com, Wednesday, March 17, 2010, 11:44 (5366 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

Re: Attempted to read or write protected memory.

by wodDamir, Wednesday, March 17, 2010, 12:15 (5366 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

Re: Attempted to read or write protected memory.

by Paul, Monday, December 16, 2013, 16:06 (3996 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 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.

by wodDrazen, Monday, December 16, 2013, 16:19 (3996 days ago) @ Paul

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.

by Paul, Monday, December 16, 2013, 16:53 (3996 days ago) @ wodDrazen

Same result I'm afraid.

Re: Attempted to read or write protected memory.

by wodSupport, Monday, December 16, 2013, 16:45 (3996 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

Re: Attempted to read or write protected memory.

by Paul, Monday, December 16, 2013, 17:03 (3996 days ago) @ wodSupport

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

Re: Attempted to read or write protected memory.

by wodSupport, Monday, December 16, 2013, 17:13 (3996 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

Re: Attempted to read or write protected memory.

by Paul, Monday, December 16, 2013, 18:51 (3995 days ago) @ wodSupport

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

Re: Attempted to read or write protected memory.

by wodSupport, Monday, December 16, 2013, 18:52 (3995 days ago) @ Paul

Paul,

cool! I'm glad it's solved!

Best regards,
Kreso