forked from krb5/krb5
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block library unloading to avoid finalizer races
Library finalizers can run due to the library being unloaded or the process exiting. If the library is being unloaded, global memory resources must be released to avoid memory leaks. But if the process is exiting, releasing memory resources can lead to race conditions if another thread invokes functions from the library during or after finalizer execution. Most commonly this manifests as an assertion error about trying to lock a destroyed mutex. We can block unloading of our library on ELF platforms by passing "-z nodelete" to the linker. Add a shell variable "lib_unload_prevented" to the shlib.conf outputs, set it on platforms where we can block unloading, and suppress finalizers when it is set. On Windows we can detect if the process is exiting by checking for a non-null lpvReserved argument in DllMain(). Do not execute finalizers when the process is executing. ticket: 9139 (new)
- Loading branch information
1 parent
b9b654e
commit 6112018
Showing
4 changed files
with
37 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters