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

loading dylib from rust host program with libloading, recompiling dylib, reloading dylib does not see the new plugin version until the host fully restarts #108

Closed
klebs6 opened this issue Aug 11, 2022 · 2 comments

Comments

@klebs6
Copy link

klebs6 commented Aug 11, 2022

Greetings folks! I have been enjoying working with the library so far! I am encountering an unexpected behavioral error, though...

It is possible that there is some simple, obvious mistake in my setup and I will find it first thing in the morning!

I figured I would post here just in case there is somebody who might already know what to do.

I can add more detail after getting some sleep, but the basic gist is that I am writing a plugin (in rust) for a host (in rust), and am using the libloading library to handle the symbol loading etc at the interface.

Most everything seems to be working quite well -- the plugin loads on demand and the code executes as I expect it to.

However, when I need to make a change to the plugin and recompile it with cargo, reloading the dylib from the host does not seem to see the new changes. If I exit the host, relaunch the host, and load the plugin once more on demand, it picks up the new changes.

My first attempt at a solution was to manually call close on the libloading::Library after I am done using the plugin, before reloading it. That didn't seem to work, though it is possible I made a mistake.

I have not had a chance to inspect the situation more deeply, but am also not quite sure yet where to start...

I think getting some sleep might help! I am off to take care of that now! 😁😴 Thanks in advance for any help!

@klebs6
Copy link
Author

klebs6 commented Aug 11, 2022

ah, looks to be the same/similar issue to #59
will try the solution there in the morning! closing for now!

@klebs6 klebs6 closed this as completed Aug 11, 2022
@nagisa
Copy link
Owner

nagisa commented Aug 11, 2022

Yeah, most likely reason is that the old library remains loaded for one reason or another and trying to load a new one just increments a reference count for the old one rather than loading a new one.

This can happen for various reasons depending on the platform being targeted so unfortunately there isn’t really a nice straightforward cross-platform solution to this.

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