From: Jérémie Galarneau Date: Wed, 3 Nov 2021 02:31:15 +0000 (-0400) Subject: Fix: sessiond: snapshot: leak of trace chunk X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a49a92168370faa70db89ec73b41fbcb7af531e8;p=lttng-tools.git 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 Change-Id: I4b6e45df48c3daafa2294c80ccd8a2b4d91401e1 --- diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 6bdfe30c1..b4bd6b43f 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -5176,6 +5176,9 @@ error_close_trace_chunk: session->name); ret_code = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER; } + + lttng_trace_chunk_put(snapshot_trace_chunk); + snapshot_trace_chunk = NULL; error: if (original_ust_consumer_output) { session->ust_session->consumer = original_ust_consumer_output;