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

Fixes pthread leak #4037

Merged
merged 7 commits into from
Jun 12, 2023
Merged

Fixes pthread leak #4037

merged 7 commits into from
Jun 12, 2023

Conversation

maddeleine
Copy link
Contributor

@maddeleine maddeleine commented Jun 6, 2023

Resolved issues:

resolves #3990
resolves #4042

Description of changes:

This change fixes the remaining pthread keys issue. We don't properly clean up our pthread key, which wouldn't matter if users don't call s2n_init more than once per process. However, in the case where you're creating threads inside of a loop and calling s2n_init in each thread, you will keep creating pthread keys and never cleaning them up and sooner or later you hit the pthread key limit.
I also added an explanation for how our auto-cleanup stuff works. Possibly we should rewrite this code so it isn't so confusing, but for now, this will help me remember how this stuff works the next time I have to touch it.

Call-outs:

Had to use a global variable to capture the output of pthread_key_create. Not exactly sure how to feel about that.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@maddeleine maddeleine requested a review from dougch as a code owner June 6, 2023 00:38
@github-actions github-actions bot added the s2n-core team label Jun 6, 2023
@maddeleine maddeleine changed the title Fixed pthread leak Fixes pthread leak Jun 6, 2023
@maddeleine maddeleine requested a review from lrstewart June 6, 2023 20:14
utils/s2n_random.c Outdated Show resolved Hide resolved
@maddeleine maddeleine requested review from lrstewart and camshaft June 7, 2023 21:56
@maddeleine maddeleine requested a review from lrstewart June 8, 2023 19:58
@maddeleine maddeleine enabled auto-merge (squash) June 12, 2023 17:32
@maddeleine maddeleine merged commit ba2ffa8 into main Jun 12, 2023
@maddeleine maddeleine deleted the pthread_leak branch June 12, 2023 18:18
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Atexit handler and other auto-cleanup behavior is not documented Pthread key resource leak
4 participants