You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue I'm seeing: Calling lib_func from the main loop initially prints Cell: 1 as expected. If you change the value to say, 2, within the RefCell in lib_func and recompile, the main loop will still repeatedly print Cell: 1.
If you replace the RefCell with a plain Cell, then once changing the value to 2 and recompiling, it would start printing Cell: 2, as I would expect.
The Box<u8> within the RefCell can be replaced with any other heap-allocated object such as a String or Vec to see the same unexpected behavior.
The text was updated successfully, but these errors were encountered:
collinoc
changed the title
TLS with RefCell with heap-allocated object produces unexpected plugin loading behavior
TLS with RefCell with heap-allocated object produces unexpected plugin re-loading behavior
Apr 26, 2024
collinoc
changed the title
TLS with RefCell with heap-allocated object produces unexpected plugin re-loading behavior
TLS with RefCell with heap-allocated object produces unexpected DSL re-loading behavior
Apr 26, 2024
collinoc
changed the title
TLS with RefCell with heap-allocated object produces unexpected DSL re-loading behavior
Thread-local RefCell containing heap-allocated object produces unexpected library re-loading behavior
May 22, 2024
You are aware that what you are doing here is highly platform dependant.
For example musl-libc doesnt even support library unloading. Its a noop there.
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: