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

Don't try to free DLL on drop #1089

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Conversation

ChrisDenton
Copy link
Member

Unloading DLLs is an extremely unsafe operation and should not be done without due caution. It's much safer to simply leak it unless we know for certain that it's safe to unload (which is hard to do without co-operations from the DLL itself).

Currently a mitigating factor is that we only use LibraryHandle for kernel32.dll, which is highly unlikely to ever be unloaded, so it's essentially a no-op anyway. However, it would become more of a problem if we ever use LibraryHandle for other DLLs.

Unloading DLLs is an extremely unsafe operation and should not be done without due caution.
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense, IIRC musl also does the same to avoid the tricky global destructor in dynlib.

@NobodyXu NobodyXu merged commit a6a928e into rust-lang:main Jun 7, 2024
24 checks passed
@ChrisDenton ChrisDenton deleted the no-free branch June 7, 2024 22:55
arttet added a commit to arttet/cc-rs that referenced this pull request Sep 27, 2024
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

Successfully merging this pull request may close these issues.

2 participants