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

Make server::router not move-able. #131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

kar8uncle
Copy link

@kar8uncle kar8uncle commented Jan 2, 2025

Issue

As explained in #130. With this change I no longer see the crash I was seeing.

I did not try building with the examples and tests. Feel free to make changes to make those pass.

Commit Message

Routes added to the router have a raw reference to the router itself.
When a router is moved, even though all the members are moved, the
raw references would not update themselves, which makes them dangling.

Downgrade router from move-able to non-move-able, and make
routing_context store a unique_ptr to router instead of an object.
This way, moving the routing_context would not end up creating a
new router, so references stored in the routes would remain valid.

Routes added to the router have a raw reference to the router itself.
When a router is moved, even though all the members are moved, the
raw references would not update themselves, which makes them dangling.

Downgrade router from move-able to non-move-able, and make
routing_context store a unique_ptr to router instead of an object.
This way, moving the routing_context would not end up creating a
new router, so references stored in the routes would remain valid.
@kar8uncle kar8uncle changed the title #130 Make server::router not move-able. Make server::router not move-able. Jan 2, 2025
@@ -14,7 +14,8 @@ using namespace malloy::server;

routing_context::routing_context(config cfg) :
m_cfg{std::move(cfg)},
m_router{m_cfg.logger != nullptr ? m_cfg.logger->clone("router") : nullptr, m_cfg.agent_string}
m_router{new server::router{m_cfg.logger != nullptr ? m_cfg.logger->clone("router") : nullptr,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor is private 😢 Cannot use make_unique.

@Tectu
Copy link
Owner

Tectu commented Jan 2, 2025

Thanks!

I'll need a bit more time to dig into this.
In the meantime, I have launched the CI test suite on this PR. Let's see how well that goes :)

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

Successfully merging this pull request may close these issues.

2 participants