Skip to content

Thread locals keep Rust shared library from unloading dlclose. #59629

@Neopallium

Description

@Neopallium

OS: Ubuntu 18.04
Doesn't seem to happen on Windows, untested on MacOS.

I created cr-sys crate to wrap cr.h: A Simple C Hot Reload Header-only Library.

It works, except that each version of the plugin isn't unloaded correctly, if the plugin uses TLS destructors registered with __cxa_thread_atexit_impl.

C++ plugins can be compiled with -fno-use-cxa-atexit to disable the use of __cxa_thread_atexit. But I can't find away to do this with Rust plugins.

Right now the only work around is to not unload old plugin and make sure to use a different name for each plugin version.

Is there any way to run the TLS destructors registered by the plugin or to disable TLS destructors for a Rust shared library?

Related issue on cr.h:
fungos/cr#35

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-thread-localsArea: Thread local storage (TLS)C-bugCategory: This is a bug.O-linuxOperating system: LinuxT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions