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

Trigger dtors on unload of a shared library #3

Closed
dtolnay opened this issue Dec 29, 2018 · 2 comments
Closed

Trigger dtors on unload of a shared library #3

dtolnay opened this issue Dec 29, 2018 · 2 comments

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Dec 29, 2018

Ctors run when I load a shared library, but its dtors do not run when that library is unloaded.

As you commented in dtolnay/inventory#1 (comment), fixing this may involve changing over from atexit to __cxa_atexit.

@mmastrac
Copy link
Owner

I spent a little while building up some test cases for this and I believe that this is working for all three platform and +crt_static & -crt_static:

Linux +crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426254#L519
Linux -crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426254#L552
OSX: +crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426257#L181
OSX: -crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426257#L214
Win: +crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426261#L142
Win: -crt_static: https://travis-ci.org/mmastrac/rust-ctor/jobs/473426261#L177

I'm creating a follow-up bug on this to automate some of the testing around this, but for now I think I can call this working. I'll release 0.1.5 with some doc fixes to indicate that this crate works for bin and cdylib based on these findings.

@dtolnay
Copy link
Contributor Author

dtolnay commented Dec 29, 2018

Nice, thanks! Confirmed that it works for me on Linux.

@dtolnay dtolnay closed this as completed Dec 29, 2018
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