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

Q: Is copying the library required on *nix? #26

Open
Dietr1ch opened this issue Jan 15, 2023 · 2 comments
Open

Q: Is copying the library required on *nix? #26

Dietr1ch opened this issue Jan 15, 2023 · 2 comments

Comments

@Dietr1ch
Copy link

On *nix you can overwrite a file that's being read by another process.

https://stackoverflow.com/questions/2028874/what-happens-to-an-open-file-handle-on-linux-if-the-pointed-file-gets-moved-or-d

This should mean that the compiler can output a new dynamic library without hitting errors because there's programs still reading (soon to be older versions of) it.
When Casey presents this copy-based workaround, he's just working around the Windows FS guarantees.

Can the copy become Windows-specific?

@rksm
Copy link
Owner

rksm commented Jan 16, 2023

Hmm good question. So on macOS at least there is this problem:

Basically, unloading a library does not work and in order to get the changes we need to load from a new file.

On Linux it might be worth a try...

@Imberflur
Copy link

I'm fairly certain Linux has similar situations where the library isn't unloaded and this also prevents loading a new version with the same name.

E.g. when there are thread local destructors that haven't ran (due to the associated thread still being alive). See https://fasterthanli.me/articles/so-you-want-to-live-reload-rust.

It is also possible to overwrite the loaded library file in the sense of actually writing to the existing file and (i.e. not deleting it and creating a new one with the same name), however I have seen this cause issues/crashes (I assume due to the old thread locals still being loaded and/or other state associated with the loaded library that doesn't expect to be used with a new version of the code).

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

3 participants