-
Notifications
You must be signed in to change notification settings - Fork 101
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
Thread-local RefCell containing heap-allocated object produces unexpected library re-loading behavior #148
Comments
Trimmed down the examples and explanation for clarity. Also included Rust version info. |
You are aware that what you are doing here is highly platform dependant. Glibc to my knowlege has a refcounter and does actually to some extend unload librarys. I do not know with which criteria windows decides to remove a dll from the process address space after you call CloseHandle on the libraries handle. I personally try to never unload shared objects/libraries as most libs do not even implement unloading properly. You are probably observing just this in your example. |
I'm running into an issue with static thread local storage that contains a heap-allocated object when loading a library.
Given a simple library:
and a main program that will repeatedly load said library:
The issue I'm seeing: Calling
lib_func
from the main loop initially printsCell: 1
as expected. If you change the value to say,2
, within the RefCell inlib_func
and recompile, the main loop will still repeatedly printCell: 1
.If you replace the
RefCell
with a plainCell
, then once changing the value to2
and recompiling, it would start printingCell: 2
, as I would expect.The
Box<u8>
within theRefCell
can be replaced with any other heap-allocated object such as aString
orVec
to see the same unexpected behavior.Full Example
Rust info:
The text was updated successfully, but these errors were encountered: