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

Fix resource leak in listening thread. #18

Closed
wants to merge 1 commit into from

Conversation

ericonr
Copy link
Contributor

@ericonr ericonr commented Jun 24, 2021

The thread launched to listen on the socket while the nscd request is
processed was being written to a temporary thread_t. This means the
thread couldn't be pthread_join'd, which is what would release its
resources (which includes the memory allocated for the thread's stack),
and this allocation would live on until nscd is killed. To avoid having
to control the thread lifetime, we can simply pthread_detach it, which
makes it so returning from the thread function releases its resources.

This commit fixes an issue where practically each new nscd request would
add (thread stack size + guard page size) bytes to the memory in use by
nscd.

The thread launched to listen on the socket while the nscd request is
processed was being written to a temporary thread_t. This means the
thread couldn't be pthread_join'd, which is what would release its
resources (which includes the memory allocated for the thread's stack),
and this allocation would live on until nscd is killed. To avoid having
to control the thread lifetime, we can simply pthread_detach it, which
makes it so returning from the thread function releases its resources.

This commit fixes an issue where practically each new nscd request would
add (thread stack size + guard page size) bytes to the memory in use by
nscd.
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.

1 participant