Skip to content

Conversation

@marip8
Copy link
Contributor

@marip8 marip8 commented Aug 4, 2025

This PR adds an internal "cache" to the plugin loader to allow it to retain pointers to loaded plugins, thereby keeping the libraries that provide their functionality from being unloaded. This change helps prevent users from unintentionally unloading plugin libraries. As long as the plugin loader remains in scope, the loaded plugins should also stay in scope

}
}

TEST(BoostPluginLoaderUnit, TestPluginLoaderScope) // NOLINT
Copy link
Contributor Author

@marip8 marip8 Aug 4, 2025

Choose a reason for hiding this comment

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

@Levi-Armstrong this unit test appears to work whether or not the internal cache introduced in this PR exists.

According to ldd the unit test only links to libboost_plugin_loader_example_plugin.so and libbboost_plugin_loader.so (not the library in which the triangle plugin was implemented - libboost_plugin_loader_example_plugin_impl.so), so the unit test itself shouldn't be loading the plugin library as part of its runtime requirement.

Any idea why this would work without holding onto the pointer to the plugin internally?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the plugin_loader object which holds the pointer to the plugin (triangle factory)? So I think what you want is to place the creation of the plugin_loader object inside the brackets and have it go out of scope. Another option, if the method exist would be to remove the triangle factory from the plugin loader also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't the plugin_loader object which holds the pointer to the plugin (triangle factory)?

Yes, this PR introduces this feature. However, the unit test still succeeds without the addition of this feature.

If this unit test is run after removing b587d66 it should fail because the library should be unloaded when the plugin (i.e., triangle_factory) goes out of scope. But it doesn't, and I'm wondering why it doesn't segfault at line 441

@marip8 marip8 force-pushed the update/plugin-scope branch from 946dfb2 to be5ad64 Compare August 4, 2025 20:23
@marip8 marip8 force-pushed the update/plugin-scope branch from 05eae2b to 544333e Compare September 15, 2025 18:34
@marip8 marip8 changed the title Draft: Keep plugins in scope after loading Keep plugins in scope after loading Sep 15, 2025
@marip8 marip8 mentioned this pull request Sep 22, 2025
@marip8
Copy link
Contributor Author

marip8 commented Oct 14, 2025

Closing; addressed in #36

@marip8 marip8 closed this Oct 14, 2025
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