3

Closed

Process terminated due to unhandled exception in Finalize / Destructor

description

My application encountered the following unhandled exception that caused the process to exit:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Renci.SshNet.Common.SshConnectionException
Stack:
at Renci.SshNet.Session.SendMessage(Renci.SshNet.Messages.Message)
at Renci.SshNet.Channels.Channel.SendMessage(Renci.SshNet.Messages.Connection.ChannelCloseMessage)
at Renci.SshNet.Channels.Channel.Close(Boolean)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean)
at Renci.SshNet.Channels.Channel.Dispose(Boolean)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean)
at Renci.SshNet.Sftp.SubsystemSession.Finalize()

__This occurred just over 60 seconds after the Dispose method on SftpClient was called which generated a very similar exception (handled and logged by my code):__

2013-02-16 15:41:32.9693 Error SftpFileTransfer Renci.SshNet.Common.SshConnectionException,Client not connected., at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.SendMessage(ChannelCloseMessage message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Dispose()
at BusinessObjects.SftpFileTransfer.DownloadFiles()


It looks like ~SubsystemSession() is causing an attempt to send a message over the channel(!) due to the chaining of calls to the various Dispose() methods.
Closed Apr 6 at 3:56 PM by drieseng

comments

OnTheBend wrote Feb 25, 2013 at 5:28 PM

Sorry, forgot to add: I am using AssemblyVersion("2013.1.27")

SergeyOsten wrote Mar 6, 2013 at 12:09 PM

I have same problem .
    public void Put()
    {
        using (var sftp = new SftpClient("127.0.0.1", 2222, "**", "123"))
        {
            try
            {
                sftp.Connect();
                        using (var streamFile = File.OpenRead(@"C:\temp\1\as1d_6.txt"))
                        {
                            sftp.UploadFile(streamFile, "/qq/1s.txt");
                        }

                sftp.Disconnect();

            }

            catch (Exception ex)
            {
                textBox1.Text = ex.Message;
            }
            finally
            {
                if (sftp != null)
                {
              sftp.Disconnect();
              sftp.Dispose();
                }
            }
        }
    }
when sftp server down I have unhadled exception

shNet.Common.SshConnectionException: Client not connected.
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.SendMessage(ChannelCloseMessage message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Channels.ChannelSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Finalize()

SergeyOsten wrote Mar 6, 2013 at 12:26 PM

how i can change impact on high?

BeyersCronje wrote Mar 6, 2013 at 12:30 PM

Yep I also have the same issue. See this discussion thread for more info.

I would also say the impact of this bug is quite high as it causes the whole app to crash.

olegkap wrote Mar 7, 2013 at 4:42 PM

Hi guys,

Can you please check 23469 commit and see if it fixes your issue?

Apparently what was happening is that I was trying to send close command when object was disposing no longer connected.

I hope it should no longer be an issue since I added connectivity check.

Thanks,
Oleg

wvandoesburg wrote Nov 18, 2013 at 3:00 PM

Hi Oleg,

I also encountered this issue in version 2013.4.7.

When do you have a new release scheduled? This issues is really killing my application "literally".

Regards,
Willem

wvandoesburg wrote Nov 21, 2013 at 1:23 PM

I've tested this issue using the current codebase (revision 32250).

I'm still seeing this problem.

The classification "resolved" does not seem correct.