Project

General

Profile

Actions

Bug #307

closed

lttng-ust threads should be created in DETACHED state as they are never joined

Added by Michael Greene almost 12 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Normal
Target version:
-
Start date:
07/16/2012
Due date:
% Done:

0%

Estimated time:

Description

When running the sample program or one of my programs, Valgrind reports the thread created in lttng_ust_init as leaked:

==19830== 320 bytes in 1 blocks are possibly lost in loss record 3 of 4
==19830==    at 0x4C279F2: calloc (vg_replace_malloc.c:467)
==19830==    by 0x4011874: _dl_allocate_tls (dl-tls.c:300)
==19830==    by 0x5E23B68: pthread_create@@GLIBC_2.2.5 (allocatestack.c:571)
==19830==    by 0x503A5E9: lttng_ust_init (lttng-ust-comm.c:907)
==19830==    by 0x400EB55: call_init.part.0 (dl-init.c:85)
==19830==    by 0x400EC2E: _dl_init (dl-init.c:52)
==19830==    by 0x40015E9: ??? (in /lib/x86_64-linux-gnu/ld-2.13.so)
==19830== 
==19830== 320 bytes in 1 blocks are possibly lost in loss record 4 of 4
==19830==    at 0x4C279F2: calloc (vg_replace_malloc.c:467)
==19830==    by 0x4011874: _dl_allocate_tls (dl-tls.c:300)
==19830==    by 0x5E23B68: pthread_create@@GLIBC_2.2.5 (allocatestack.c:571)
==19830==    by 0x503A613: lttng_ust_init (lttng-ust-comm.c:913)
==19830==    by 0x400EB55: call_init.part.0 (dl-init.c:85)
==19830==    by 0x400EC2E: _dl_init (dl-init.c:52)
==19830==    by 0x40015E9: ??? (in /lib/x86_64-linux-gnu/ld-2.13.so)

I have not been able to fix this problem. However, during the investigation of this problem, I noticed that the threads are being created in the default state but are never intended to be explicitly detached or joined. If pthread_detach or pthread_join is never called, the thread should be created with the PTHREAD_CREATE_DETACHED detach state so that their storage can be reclaimed when the thread terminates.

To be clear, this patch does not fix my problem with Valgrind, but it changes behavior to match the spec.


Files

Actions

Also available in: Atom PDF