From 38aea171b4c78a7a905ba7b725e51c5836f3574c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 3 Mar 2022 17:52:33 -0500 Subject: [PATCH] Fix: ust-consumerd: leak of stream control structure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The following leak is reported by LeakSanitizer when setup_metadata() fails to send the metadata stream to the relay daemon: ==3050181==ERROR: LeakSanitizer: detected memory leaks Direct leak of 240 byte(s) in 5 object(s) allocated from: #0 0x7f5fce02cfb9 in __interceptor_calloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154 #1 0x7f5fcdd95a7a in zmalloc ../../../src/common/macros.h:23 #2 0x7f5fcdd95a7a in lttng_ust_ctl_create_stream /home/jgalar/EfficiOS/src/lttng-ust/src/lib/lttng-ust-ctl/ustctl.c:1649 A consumer stream can have an allocated `struct lttng_ust_ctl_consumer_stream *` (ustream) even if it is not globally visible at the time of its teardown. In the case of the user space consumer, the only site that creates consumer stream instances ensures that the allocation of the lttng_ust_ctl_consumer_stream succeeded, ensuring that the consumer stream's 'ustream' is always set. Signed-off-by: Jérémie Galarneau Change-Id: Ia4be7969e85bd8812ae13b042e1e100812a63c1d --- src/common/consumer/consumer-stream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp index 2dc3f002b..479667209 100644 --- a/src/common/consumer/consumer-stream.cpp +++ b/src/common/consumer/consumer-stream.cpp @@ -1092,6 +1092,7 @@ void consumer_stream_destroy(struct lttng_consumer_stream *stream, * If the stream is not visible globally, this needs to be done * outside of the consumer data lock section. */ + destroy_close_stream(stream); free_chan = unref_channel(stream); } -- 2.34.1