Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for thread local storage destruction order
The current OPENSSL_thread_stop() mechanism uses thread local storage to store cleanup handlers for the various threads. When a thread exits the destructor for the thread local storage gets called and we can call the various handlers. The handlers assume that they can still access the thread local storage for that particular part of the code - but this relies on the OPENSSL_thread_stop() thread local storage being destroyed first. If happens in a different order then glibc seems to NULL out thread local storage that hasn't been explicitly destroyed causing a memory leak. glibc seems to call the destructors in the same order that the keys were created, so we workaround this by always ensuring that the OPENSSL_thread_stop() key is always created first. This is only a workaround because it assumes a particular implementation in glibc. We need a better solution. We also revert an earlier change in test/threadstest.h. This was only necessary because of this problem and masked the real issue.
- Loading branch information