Search code examples
c++sslboostopenssl

boost::asio::ssl::context crash during construction


I can't figure why the following instruction crashes:

boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv12);

I got the following error: Process returned -1073741819 (0xC0000005)

There is nothing more to catch regarding exceptions and AFAIK the boost documentation doesn't mention incompatibility issues between the boost and openssl versions.

my environment:

gcc from cygwin: C:\cygwin64\x86_64-w64-mingw32-g++.exe

linker options: -lws2_32 -lcrypto -lssl

using boost 1.78 (dl from website) and cygwin's openssl 1.1.1m packages

here is the minimal example:

#include <iostream>
#include <boost/asio/ssl/context.hpp>


int main()
{
    std::cout << "before" << std::endl;
    try {
        boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv12);
    } catch (...) {
        std::cout << "catch" << std::endl;
    }
    std::cout << "after" << std::endl;

    return 0;
}

output:

before

Solution

  • The openssl cygwin package I installed is not a stable one, so the include and lib files are missing and I'm using the wrong ones (incompatible with the x86_64-w64-mingw32-g++ compiler). I've installed another stable version and the desired files are available now.