Here is the relevant code base, the use-after-free is on the `co_await(in.consume...)` line.
Am I missing something in my implementation here, i.e is this a real bug on my end?
#include <seastar/core/app-template.hh>
#include <seastar/core/iostream.hh>
#include <seastar/core/future.hh>
#include <seastar/coroutine/all.hh>
#include <seastar/http/client.hh>
#include <seastar/http/request.hh>
#include <seastar/http/reply.hh>
#include <fmt/printf.h>
using namespace seastar;
struct printer {
future<consumption_result<char>> operator() (temporary_buffer<char> buf) {
if (buf.empty()) {
return make_ready_future<consumption_result<char>>(stop_consuming(std::move(buf)));
}
fmt::print("{}", sstring(buf.get(), buf.size()));
return make_ready_future<consumption_result<char>>(continue_consuming());
}
};
future<int> http_tester() {
auto req = http::request::make("GET", "127.0.0.1", "/");
socket_address addr{ipv4_addr("127.0.0.1", 9090)};
http::experimental::client http_client{addr};
co_await http_client.make_request(std::move(req),
[](const http::reply& rep, input_stream<char>&& in) mutable -> future<> {
co_await in.consume(printer{});
co_await in.close();
});
co_await http_client.close();
co_return 0;
}
int main(int argc, char** argv) {
app_template app;
return app.run(argc, argv, [&]() -> future<int> { return http_tester(); });
}