Stop() behaviour & Access Violation - WeOnlyDo Discussion board

Stop() behaviour & Access Violation (wodSSHServer)

by David Lucas, Wednesday, January 04, 2006, 16:16 (6908 days ago)

We are developing an application in C++ Builder 6 under Windows XP and we've recently encountered a problem when attempting to call TwodSSHDCom's Stop() method - the clients remain connected. You can even delete the TwodSSHDCom object without the client realising that the connection has gone. The client only realises the connection has been terminated when TwodSSHDCom's owning process is terminated.

While attempting to resolve this in a small test application we also noted an access violation that occurs when deleting TwodSSHDCom while clients are connected (this only seems to apply to SSH and doesn't occur if the client is not yet authenticated). We have updated to the latest version of TwodSSHDCom, but the results are the same.

Here is the code used to create TwodSSHDCom:

Server = new TwodSSHDCom((TComponent*)NULL);

WideString Filename = c:\mykey.rsa ;
if(FileExists(Filename))
{
Server->Keys->Load(Filename);
}
else
{
Server->Keys->Generate(RSAkey);
Server->Keys->Save(RSAkey, Filename);
}

Server->set_Port(5000);
// Event handler that just sets Accept to true.
Server->OnLoginPassword = ServerLoginPassword;

Server->Start();


And here is the code used to delete it:

Server->Stop();
delete Server;
Server = NULL;


Regards,

David Lucas
Data Track Technology

Re: Stop() behaviour & Access Violation

by wodSupport, Wednesday, January 04, 2006, 19:24 (6908 days ago) @ David Lucas

David,

any chance you can send that BCB project, together with EXE file, to techsupport@weonlydo.com ?

Thanks,
Kreso

Re: Stop() behaviour & Access Violation

by wodSupport, Wednesday, January 04, 2006, 19:26 (6908 days ago) @ wodSupport

What I think could be happening here is that you hold references to Users object, so that when we release it (in Stop method) it's not destroyed.

I can change wodSSHServer so it kills connections when Stop is called, even collection of users isn't destroyed by itself. I guess this is a safe precaution, but I'm not sure if it will still solve your problem.

Re: Stop() behaviour & Access Violation

by wodSupport, Wednesday, January 04, 2006, 19:42 (6908 days ago) @ wodSupport

David,

I made that change. Can you please request update and try it now?

Re: Stop() behaviour & Access Violation

by wodSupport, Friday, January 06, 2006, 01:41 (6907 days ago) @ wodSupport

Ok, I made additional change, but only to protect myself against crash. You can request update.

Real problem still remains - you're holding one reference too many (perhaps not by your fault). In LoginPassword event, you must release User object, and that should fix the problem even with the version you already have.

Can you try that?