Archived Forum Post

Index of archived forum posts


Access violation with ConnectAsync (C++)

Feb 07 '17 at 13:07

The demonstration code at crashes with an access violation if the server does not support TLS. I believe this happens while (connectTask->get_Finished() != true){} is still spinning. It should return a catchable error instead. I used on localhost with echotool /p tcp /s 443 as the command line argument for my server (but presumably the effect will exist with other servers.

If the server is not launched, the while loop exits cleanly. If I set useTls to false, the while loop exits cleanly.

I've pasted the call stack on crash below. I'm using Visual Studio 2013 and a basic console application.

ConsoleApplication1.exe!TlsProtocol::clientHandshake2(bool,class TlsEndpoint &,class _clsTls &,unsigned int,class SocketParams &,class LogBase &)   C++
ConsoleApplication1.exe!TlsProtocol::clientHandshake(bool,class chilkat::StringBuffer const &,class TlsEndpoint &,class _clsTls &,unsigned int,class SocketParams &,class LogBase &)    C++
ConsoleApplication1.exe!SChannelChilkat::connectImplicitSsl(class chilkat::StringBuffer const &,int,class _clsTls &,unsigned int,class SocketParams &,class LogBase &)  C++
ConsoleApplication1.exe!Socket2::connect2(class chilkat::StringBuffer const &,int,bool,class _clsTls &,class SocketParams &,class LogBase &)    C++
ConsoleApplication1.exe!Socket2::socket2Connect(class chilkat::StringBuffer const &,int,bool,class _clsTls &,unsigned int,class SocketParams &,class LogBase &) C++
ConsoleApplication1.exe!ClsSocket::clsSocketConnect(class XString &,int,bool,int,class SocketParams &,class LogBase &)  C++
ConsoleApplication1.exe!ClsSocket::Connect(class XString &,int,bool,int,class ProgressEvent *)  C++
ConsoleApplication1.exe!fn_socket_connect(class ClsBase *,class ClsTask *)  C++
ConsoleApplication1.exe!ClsTask::callTaskFunction(class LogBase *)  C++
ConsoleApplication1.exe!_ckThread::runThread(void)  C++
ConsoleApplication1.exe!_ckThreadPool::finalizeThreadPool(void) C++
kernel32.dll!777f7c04() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]  
[External Code]

Accepted Answer

Here are the new builds:


What version of Chilkat are you using?


I found and fixed the problem. I'll reply with a pre-release build of v9.5.0.66 once it's ready...


Thanks. The crashing is fixed. On to the next issue (or I can make a new forum question if you prefer). We have a server that supports SSL 3.0, but not SSL 2.0. Using socket.put_SslProtocol( "SSL 3.0" ); works, and using socket.put_SslProtocol( "SSL 2.0" ); fails, as it should. However, socket.put_SslProtocol( "default" ); fails, but it should not. I expect it to detect and use SSL 3.0. Note that default did work with SSL 3.0 as of chilkat version 9.3.2, which I am upgrading from.

Note that your example server ( supports SSL 2.0 but not SSL 3.0 and using default works. It may be that default always uses SSL 2.0 rather than detecting the server. If true, this would contradict the documentation at, put_SslProtocol.