Skip to content

router::make_endpt_writer_callback keeps a dangling pointer to a moved-from router? #130

@kar8uncle

Description

@kar8uncle

router::make_endpt_writer_callback seems to be keeping a dangling pointer to this.

return [this]<typename R>(const auto& req, R&& resp, const auto& conn) {

When I create a routing_context and then std::move and pass it to malloy::server::start, the router that lives in the moved-to routing_context is a different instance than when I created the routes in. The endpoint_http_regex objects created in the old router are moved, but the endpoint_http_regex::writer object:

ep->writer = make_endpt_writer_callback();

is still refering to an old router, and crashes when a request comes in.

For reference, here is how I am adding routes and starting the server:

malloy::server::routing_context ctx{m_cfg};
setup_routes(ctx.router());
m_session = std::make_unique<malloy::server::routing_context::session>(malloy::server::start(std::move(ctx)));

m_thread = std::jthread{[&session=*m_session]
{
    session.run();
}};

Is this how it is supposed to be used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions