Fix: lttng-ctl: tracing_group memory leaks
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 19 Oct 2021 19:22:39 +0000 (15:22 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 2 Nov 2021 19:23:07 +0000 (15:23 -0400)
commit76da29b633da92c9a4e0d32e67982c4608039377
treec2063beed0ab1faa5d59a13b8b2a5035e4d14117
parentacfb63a8ba86cb7d89cfeea515abceb89f2907e9
Fix: lttng-ctl: tracing_group memory leaks

Observed issue
==============

liblttng-ctl leaks memory if `lttng_set_tracing_group` is called at least
1 time by an API client.

 joraj@~/lttng/master/lttng-tools-dev [master][]$ valgrind --leak-check=full lttng --group=joraj list
 ==24823== Memcheck, a memory error detector
 ==24823== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
 ==24823== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
 ==24823== Command: lttng --group=joraj list
 ==24823==
 Error: No session daemon is available
 ==24823==
 ==24823== HEAP SUMMARY:
 ==24823==     in use at exit: 8 bytes in 1 blocks
 ==24823==   total heap usage: 55 allocs, 54 frees, 87,023 bytes allocated
 ==24823==
 ==24823== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
 ==24823==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==24823==    by 0x4BA7DC7: __vasprintf_internal (vasprintf.c:71)
 ==24823==    by 0x4C4B742: __asprintf_chk (asprintf_chk.c:34)
 ==24823==    by 0x48687D9: asprintf (stdio2.h:181)
 ==24823==    by 0x48687D9: lttng_set_tracing_group (lttng-ctl.c:2620)
 ==24823==    by 0x4011B89: call_init.part.0 (dl-init.c:72)
 ==24823==    by 0x4011C90: call_init (dl-init.c:30)
 ==24823==    by 0x4011C90: _dl_init (dl-init.c:119)
 ==24823==    by 0x4001139: ??? (in /usr/lib/x86_64-linux-gnu/ld-2.31.so)
 ==24823==    by 0x2: ???
 ==24823==    by 0x1FFEFFFCFE: ???
 ==24823==    by 0x1FFEFFFD04: ???
 ==24823==    by 0x1FFEFFFD12: ???
 ==24823==
 ==24823== LEAK SUMMARY:
 ==24823==    definitely lost: 8 bytes in 1 blocks
 ==24823==    indirectly lost: 0 bytes in 0 blocks
 ==24823==      possibly lost: 0 bytes in 0 blocks
 ==24823==    still reachable: 0 bytes in 0 blocks
 ==24823==         suppressed: 0 bytes in 0 blocks
 ==24823==
 ==24823== For lists of detected and suppressed errors, rerun with: -s
 ==24823== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Cause
=====

The allocated pointer in the library constructor is not freed on
subsequent assignation.

Solution
========

Free the pointer.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie1d4c45df2764a88c74d56de691783df9215633c
src/lib/lttng-ctl/lttng-ctl.c
This page took 0.026332 seconds and 4 git commands to generate.