Fix: sessiond: snapshot: leak of trace chunk
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 3 Nov 2021 02:31:15 +0000 (22:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 10 Dec 2021 16:31:50 +0000 (11:31 -0500)
commita49a92168370faa70db89ec73b41fbcb7af531e8
tree8ece74222fb264f253423357f6506a1d3d18eae5
parentc146266cae7ab1b542d697599097da3bffb19175
Fix: sessiond: snapshot: leak of trace chunk

Valgrind reports a leak after every snapshot record command:

==827791== 430 (280 direct, 150 indirect) bytes in 1 blocks are definitely lost in loss record 34 of 37
==827791==    at 0x48435FF: calloc (vg_replace_malloc.c:1117)
==827791==    by 0x223D01: zmalloc (macros.h:45)
==827791==    by 0x224B79: lttng_trace_chunk_allocate (trace-chunk.c:387)
==827791==    by 0x224E41: lttng_trace_chunk_create (trace-chunk.c:427)
==827791==    by 0x150B55: session_create_new_trace_chunk (session.c:656)
==827791==    by 0x164A11: snapshot_record (cmd.c:5113)
==827791==    by 0x1651EE: cmd_snapshot_record (cmd.c:5302)
==827791==    by 0x196E74: process_client_msg (client.c:2166)
==827791==    by 0x198AF1: thread_manage_clients (client.c:2742)
==827791==    by 0x18E245: launch_thread (thread.c:66)
==827791==    by 0x4B9E258: start_thread (in /usr/lib/libpthread-2.33.so)
==827791==    by 0x4CB45E2: clone (in /usr/lib/libc-2.33.so)

session_set_trace_chunk() on line 5162 returns a reference to the
current trace chunk which is never released.

This also causes tests/regression/tools/snapshots/test_ust_long to fail
due to a file descriptor exhaustion (presumably from using too many
directory file descriptors) when it is executed by an unprivileged user.

The CI doesn't catch this since the long regression test suite is
executed as root.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4b6e45df48c3daafa2294c80ccd8a2b4d91401e1
src/bin/lttng-sessiond/cmd.cpp
This page took 0.024786 seconds and 4 git commands to generate.