Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runs fine on Linux, crash on Windows due to boost invalid memory access issue #1134

Open
sierret opened this issue Apr 6, 2024 · 2 comments

Comments

@sierret
Copy link

sierret commented Apr 6, 2024

For context, I'm using this in a multi-threaded environment. I run main in an infinite loop and .detach() threads and while also having a single .join() running as the main. I have some global variables accessed by the websocket as well if that matters. My application runs great on Linux but on Windows I receive the error:

terminate called after throwing an instance of 'boost::wrapexcept<boost::system::system_error>' what(): Invalid access to memory location [system:998]

It is quite strange. I also built the app using MingW(& websocketpp built using vcpkg x64-mingw-static triplet) which can be quite hit or miss sometimes requiring a lot of programmer intervention and research to get stuff compiled and linked. After successful compilation, I imagined that would be the end of MingW headache, but I don't know if it's related to that.

As this seems boost related, I wanted to try to use asio standalone. I did use the headers [ASIO_STANDALONE &
WEBSOCKETPP_CPP11_TYPE_TRAITS] but this gives issues with my code which was built for boost. If possible, I guess as a plan B, I'd need to convert this on_tls_init code below to work with asio standalone(which I have no idea how to do):

`context_ptr myfunc::on_tls_init(websocketpp::connection_hdl) {
m_tls_init = std::chrono::high_resolution_clock::now();
context_ptr ctx = websocketpp::lib::make_sharedboost::asio::ssl::context(boost::asio::ssl::context::tlsv12);

    try {
        ctx->set_options(boost::asio::ssl::context::default_workarounds |
                         boost::asio::ssl::context::no_sslv2 |
                         boost::asio::ssl::context::no_sslv3 |
                         boost::asio::ssl::context::single_dh_use);
        ctx->set_verify_mode(boost::asio::ssl::verify_none);
    } catch (std::exception& e) {
        std::cout << e.what() << std::endl;
    }
    return ctx;
}`

As well as the context_ptr def :

typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;

Please direct me to example code if already exists. Or general direction. Any help appreciated.

@sierret
Copy link
Author

sierret commented Apr 15, 2024

Issue seems Mingw related.

I compiled on MSVC and works fine.

@sierret sierret closed this as completed Apr 15, 2024
@sierret
Copy link
Author

sierret commented Apr 15, 2024

Decided to re-open issue in case of further update. But as of currently, if any one runs into similar issue please compile using MSVC( thus and Visual Studio on Windows, eww) on or GCC with Linux. MingW on either Linux or Windows seems problematic.

@sierret sierret reopened this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant