Fix: src.ctf.lttng-live: using `last_inactivity_ts` uninitialized
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 10 Nov 2021 18:16:15 +0000 (13:16 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 11 Nov 2021 22:47:54 +0000 (17:47 -0500)
commita043c3621976126dfaaaf8ffa2ee7fd5d98ea33b
tree17bab3dd125de17d17223b194a7bef285001fdf0
parent285951be2bbbbf5a22c1b012fadf5bd285f2f631
Fix: src.ctf.lttng-live: using `last_inactivity_ts` uninitialized

Observed issue
==============
I saw the following error message in the logs of a `lttng clear` test case
crash:

  bt_clock_class_cycles_to_ns_from_origin@clock-class.c:311 Cannot convert cycles to nanoseconds from origin for given clock class: value overflows the signed 64-bit integer range:
    cc-addr=0x55f5b33280f0, cc-name="monotonic", cc-freq=1000000000,
    cc-partial-descr="Monotonic Clock",
    cc-uuid="c812f5e1-ceda-4f13-8b99-23a5be8a2908",
    cc-is-frozen=0, cc-precision=0, cc-offset-s=1634653310,
    cc-offset-cycles=492621904, cc-origin-is-unix-epoch=1,
    cc-base-offset-ns=1634653310492621904, cc-cs-pool-size=6, cc-cs-pool-cap=15,
    cycles=9223372036854775808

Take note that last line of this log statement shows a `cycles` value of
9223372036854775808. This value is `INT64_MIN` stored on a 64bits
unsigned integer.

Cause
=====
This error occurs because the
`lttng_live_stream_iterator::last_inactivity_ts` field is used without
being initialized to an actual value.

This field is a `uint64_t` and is initialized to `INT64_MIN` with the
intent of setting it to the minimum value and used as is in that error
statement.

Fix
===
Change the `last_inactivity_ts` field to an anonymous struct that
contains an `is_set` boolean and the value. Use the `is_set` flag to
ensure we only use this field once initialized.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I24ba0dd9267508b2c9f0de99386a16b1ce022329
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6677
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/lttng-live/data-stream.c
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h
This page took 0.024985 seconds and 4 git commands to generate.