From d05185faf74eddb5d0425822efc877c6c0ce5f0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 8 Aug 2019 16:39:56 -0400 Subject: [PATCH] Fix: initialize kernel stream max subbuffer size on creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit A consumer stream's maximal subbuffer size is only initialized while taking a snapshot. This unexpectedly leaves the max_sb_size at 0 causing the rotation target sequence number computation to crash with a SIGFPE. This fix initializes the value as soon as possible to provide a behaviour in line with that of the ust-consumer. Signed-off-by: Jérémie Galarneau --- src/common/kernel-consumer/kernel-consumer.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 29ccd0f09..9742ea084 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -231,15 +231,6 @@ static int lttng_kconsumer_snapshot_channel( goto end_unlock; } - if (stream->max_sb_size == 0) { - ret = kernctl_get_max_subbuf_size(stream->wait_fd, - &stream->max_sb_size); - if (ret < 0) { - ERR("Getting kernel max_sb_size"); - goto end_unlock; - } - } - consumed_pos = consumer_get_consume_start_pos(consumed_pos, produced_pos, nb_packets_per_stream, stream->max_sb_size); @@ -668,6 +659,14 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, new_stream->chan = channel; new_stream->wait_fd = fd; + ret = kernctl_get_max_subbuf_size(new_stream->wait_fd, + &new_stream->max_sb_size); + if (ret < 0) { + pthread_mutex_unlock(&channel->lock); + ERR("Failed to get kernel maximal subbuffer size"); + goto end_nosignal; + } + consumer_stream_update_channel_attributes(new_stream, channel); switch (channel->output) { -- 2.34.1