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

Memory leak in OpenSSL thread state #72774

Closed
tiran opened this issue Nov 2, 2016 · 2 comments
Closed

Memory leak in OpenSSL thread state #72774

tiran opened this issue Nov 2, 2016 · 2 comments
Assignees
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir performance Performance or resource usage topic-SSL

Comments

@tiran
Copy link
Member

tiran commented Nov 2, 2016

BPO 28588
Nosy @tiran

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/tiran'
closed_at = <Date 2017-09-07.20:39:37.305>
created_at = <Date 2016-11-02.12:01:29.938>
labels = ['extension-modules', 'expert-SSL', '3.7', 'performance']
title = 'Memory leak in OpenSSL thread state'
updated_at = <Date 2017-09-07.20:39:37.303>
user = 'https://github.com/tiran'

bugs.python.org fields:

activity = <Date 2017-09-07.20:39:37.303>
actor = 'christian.heimes'
assignee = 'christian.heimes'
closed = True
closed_date = <Date 2017-09-07.20:39:37.305>
closer = 'christian.heimes'
components = ['Extension Modules', 'SSL']
creation = <Date 2016-11-02.12:01:29.938>
creator = 'christian.heimes'
dependencies = []
files = []
hgrepos = []
issue_num = 28588
keywords = []
message_count = 2.0
messages = ['279922', '301626']
nosy_count = 1.0
nosy_names = ['christian.heimes']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue28588'
versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

@tiran
Copy link
Member Author

tiran commented Nov 2, 2016

Quote from curl/curl#964

---
I wrote to Matt Caswell from openssl.org about this memleah, and he answered:
OpenSSL maintains a separate error queue for each thread. On each queue there can be
multiple errors. ERR_get_state() does not add any errors to the queue it
merely returns the ERR_STATE (i.e. the queue) for the current thread.
If the current thread has no queue then ERR_get_state() will create one.

ERR_clear_error() removes all the errors that are on the current
thread's queue. It does not deallocate the current thread's queue.

ERR_remove_thread_state() deallocates the specified thread's queue.

The mem leaks you are seeing are almost certainly because the queues for
your app's threads have not been deallocated.
---

The memory leak only affects OpenSSL 1.0.2 and older. OpenSSL 1.1.0 takes care of threading, locking and thread local resources itself.

@tiran tiran added the 3.7 (EOL) end of life label Nov 2, 2016
@tiran tiran self-assigned this Nov 2, 2016
@tiran tiran added extension-modules C modules in the Modules dir topic-SSL performance Performance or resource usage labels Nov 2, 2016
@tiran
Copy link
Member Author

tiran commented Sep 7, 2017

It's rather painful to fix the issue. Since the memory leak only affects users that create and destroy a lot of threads and the bug has been addressed by OpenSSL 1.1.0, I won't fix it.

If users are running into the issue, they should rather update to more recent OpenSSL versions. The 1.1.0 series uses proper thread local storage.

@tiran tiran closed this as completed Sep 7, 2017
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir performance Performance or resource usage topic-SSL
Projects
None yet
Development

No branches or pull requests

1 participant