ObjectDisposedException Using SFTP

0 votes
asked Mar 28, 2012 by Trev (120 points)
edited Mar 28, 2012

Hi,

We are observing intermittent errors when calling GetFile(remotPath, localPath)...

The stacktrace is shown below...

This does not happen all the time (seems that the occurrence may be related to large files / specific server type).

The application is multi-threaded but at the time the error is thrown, no other threads are executing (or have been executing prior to the running thread being invoked).

Any help greatly appreciated...

Stacktrace:

System.ObjectDisposedException: Safe handle has been closed
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at System.Security.Cryptography.CapiNative.UnsafeNativeMethods.CryptDecrypt(SafeCapiKeyHandle hKey, SafeCapiHashHandle hHash, Boolean Final, Int32 dwFlags, IntPtr pbData, Int32& pdwDataLen)
   at System.Security.Cryptography.CapiSymmetricAlgorithm.RawDecryptBlocks(Byte[] buffer, Int32 offset, Int32 count)
   at System.Security.Cryptography.CapiSymmetricAlgorithm.DecryptBlocks(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[] outputBuffer, Int32 outputOffset)
   at System.Security.Cryptography.CapiSymmetricAlgorithm.TransformBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[] outputBuffer, Int32 outputOffset)
   at wWGvS.AIchsYZ.AcUJKJ(Byte[] )
   at Rebex.Net.SshSession.AePCoRZ(Byte[]& )
   at Rebex.Net.SshSession.cDtmAOZ(cMbfbTZ , Object[] )
   at Rebex.Net.SshChannel.cDtmAOZ(Boolean , cMbfbTZ , Object[] )
   at Rebex.Net.SshChannel.Receive(Byte[] buffer, Int32 offset, Int32 count)
   at wWGvS.AzRMspZ.BMJzdYZ(Byte[] , Int32 , Int32 )
   at wWGvS.APnbEo.BXQTfX(Int32 )
   at wWGvS.APnbEo.CFLiXJ(BBdsJfZ& )
   at wWGvS.APnbEo.CFLiXJ(UInt32 )
   at wWGvS.APnbEo.BdgSrC(UInt32 )
   at Rebex.Net.Sftp.CipxfYZ(AYPecc , String , Stream , Int64 , Int64 )
   at Rebex.Net.Sftp.CipxfYZ(FileMode , AYPecc , String , String , Int64 , Int64 , Int64 )
   at Rebex.Net.Sftp.GetFile(String remotePath, String localPath)
Applies to: Rebex SFTP

1 Answer

0 votes
answered Mar 28, 2012 by Lukas Pokorny (121,750 points)
edited Mar 28, 2012

This looks like the instance of System.Security.Cryptography.ICryptoTransform used for decryption of SSH session data was disposed.

From the stack trace, it looks like you are using Rebex SFTP v2.0.4086.0 or earlier. Would it be possible to try the latest release, Rebex SFTP 2012 R1? There were actually some changes in how instances of ICryptoTransform are disposed, so it's quite possible the new version already solves this (or at least produces a different error).

commented Mar 28, 2012 by Trev (120 points)
edited Mar 28, 2012

Brilliant!

Thanks for the quick response...

I will try the latest version and see if we observe the same issue again...

commented Mar 28, 2012 by Lukas Pokorny (121,750 points)
edited Mar 28, 2012

Thanks! If you do observer the issue with the new version as well, please post an updated stack trace and a log produced using Sftp object's LogWriter property (as described at http://www.rebex.net/kb/logging.aspx).

...