thread heap leak?
Carlos O'Donell
codonell@redhat.com
Fri Mar 22 17:03:00 GMT 2019
On 3/22/19 10:53 AM, David Muse wrote:
> We have this little server program that listens for client
> connections on an inet socket. When it receives a connection, it
> pthread_create()'s a detached thread to handle the request and the
> main thread waits for more client connections.
The stack for the detached thread is recoverable only if the thread
exits, at which point it calls __free_tcb () (only if detached,
because otherwise only pthread_join() does this recovery), enqueues
the stack onto the free list and leaves it there. Subsequent thread
creation attemps to reuse the stack, but must wait for the kernel
to clear the registered tid memory (CLONE_CHILD_CLEARTID) to mark
the stack reusable (FREE_P). The total size of the thread stack
cache should only be ~40MiB, and new stack creation triggers an
automatic check to trim this cache back down to 40MiB.
Have you been able to reduce this to a smaller test case?
The anonymous mappings might indeed be thread stacks, but you'd
have to verify that yourself, and you can do that by asking the
thread for the stack information and printing that.
Are you using Amazon Linux or a known distro upstream?
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list