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

cpp20_intro.cpp example crashes with Boost.Async #137

Open
mzimbres opened this issue Aug 13, 2023 · 0 comments
Open

cpp20_intro.cpp example crashes with Boost.Async #137

mzimbres opened this issue Aug 13, 2023 · 0 comments

Comments

@mzimbres
Copy link
Collaborator

The example below will crash with Boost.Async

#include <boost/asio.hpp>
#include <boost/async.hpp>
#include <boost/redis.hpp>
#include <iostream>

#include <boost/redis/src.hpp>

namespace async = boost::async;
namespace asio = boost::asio;

using boost::redis::request;
using boost::redis::response;
using boost::redis::config;
using boost::redis::connection;

async::detached run(std::shared_ptr<connection> conn)
{
   co_await conn->async_run({}, {}, async::use_op);
}

async::main co_main(int argc, char **argv)
{
   auto conn = std::make_shared<connection>(co_await async::this_coro::executor);

   run(conn);

   request req;
   req.push("PING", "Hello world");

   response<std::string> resp;

   co_await conn->async_exec(req, resp, async::use_op);
   conn->cancel();

   std::cout << "PING: " << std::get<0>(resp).value() << std::endl;
   co_return 0;
}

Output:

debian2[0]$ ./example/boost_async_example_http 
(Boost.Redis) Resolve results: 127.0.0.1:6379
(Boost.Redis) Connected to endpoint: 127.0.0.1:6379
(Boost.Redis) Bytes written: 140
(Boost.Redis) Hello: Success
PING: Hello world
(Boost.Redis) Connection lost: Operation canceled
munmap_chunk(): invalid pointer
Aborted
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