From f3fe2a9216e46a1a10490e7457fabce7872bf5b7 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 18 Dec 2019 10:56:29 -0500 Subject: [PATCH] Fix: relayd stream.c: LTTNG_OPTIONAL_GET address confusion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The lack of proper care around use of macro arguments in LTTNG_OPTIONAL_GET allowed this code to compile, but caused the following issue (manually replacing "optional" argument with the a Using LTTNG_OPTIONAL_GET(&stream->ongoing_rotation)->next_trace_chunk with: #define LTTNG_OPTIONAL_GET(optional) \ ({ \ assert(optional.is_set); \ optional.value; \ }) translates to: ({ assert(&stream->ongoing_rotation.is_set); &stream->ongoing_rotation.value; })->next_trace_chunk The issue here is the assert(), which just checks that the address is not NULL, when it should actually check that the value is set. The prior commit fixing optional.h to add proper parentheses to the macro rightfully fails to compile this code. Fix the erroneous user. Signed-off-by: Mathieu Desnoyers Change-Id: I0dd45fb60573cae6ae3e831e24266aff4406f57f Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 4c97a609e..755fb6734 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -209,7 +209,7 @@ static int rotate_truncate_stream(struct relay_stream *stream) struct stream_fd *previous_stream_fd = NULL; struct lttng_trace_chunk *previous_chunk = NULL; - if (!LTTNG_OPTIONAL_GET(&stream->ongoing_rotation)->next_trace_chunk) { + if (!LTTNG_OPTIONAL_GET(stream->ongoing_rotation).next_trace_chunk) { ERR("Protocol error encoutered in %s(): stream rotation " "sequence number is before the current sequence number " "and the next trace chunk is unset. Honoring this " -- 2.34.1