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

Question about use case with DLL unloading #39

Open
Boscop opened this issue Oct 31, 2020 · 1 comment
Open

Question about use case with DLL unloading #39

Boscop opened this issue Oct 31, 2020 · 1 comment

Comments

@Boscop
Copy link

Boscop commented Oct 31, 2020

These are some usecases for this library:

  • Creating a plugin system (without support for unloading).

Does this mean using this crate when my plugins should support unloading would be unsafe?

In my use case I'm using this crate to auto-reload recompiled plugins:
https://crates.io/crates/dynamic_reload

My DLL entry point returns a Plugin trait object that the host takes ownership of.
And yes, I drop this trait object before unloading the DLL.
My question is, can I still use this crate?

Do I even need to, when host and plugin are always compiled with the same nightly?
(Does it make a difference if the DLL is a dylib or cdylib regarding ABI stability guarantee?)

Everything seems to work fine when using cdylib and compiling with the same nightly, even without marshalling my types across the DLL boundary, but people told me the ABI could change even between different invocations of the same rustc.

@rodrimati1992
Copy link
Owner

rodrimati1992 commented Nov 1, 2020

What you quoted means that if you use abi_stable's safe functions for loading dynamic libraries, you can't unload the dynamic library.

You can still use data structures from the crate in your project that unloads dynamic libraries. you have to ensure all* objects from the dynamic library are dropped before unloading it though, which you seem to be doing already.

*This means all abi_stable types that have vtables, or other values contaning pointers to static memory of the dynamic library.

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

2 participants