trimmer: don't get clock snapshots from messages that don't have them
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 5 May 2021 14:07:56 +0000 (10:07 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 Sep 2021 14:39:08 +0000 (10:39 -0400)
When using a trace with packets that don't have beginning clock
snapshots [1] with a trimmer component, we hit:

    $ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
    ...
    Condition ID: `pre:message-packet-beginning-borrow-default-clock-snapshot-const:msg-stream-class-packets-have-beginning-default-clock-snapshot`.
    Function: bt_message_packet_beginning_borrow_default_clock_snapshot_const().
    ------------------------------------------------------------------------
    Error is:
    Message's stream class packets don't have beginning default clock snapshot.

The problem is with the trimmer's get_msg_ns_from_origin function
assuming that that packet begnning messages have a clock snapshot if the
stream class has a clock class (which I suppose was true in early
development stages).

Fix that by making get_msg_ns_from_origin skip over messages
that don't have clock snapshots.  In addition to packet beginning
messages, I found (just by inspection, not tested) that packet end,
discarded events and discarded packets messages are in the same
situation.

Note that the trimmer component currently requires packet messages to
have clock snapshots in order to work.  However, the check for this
happens later, during the TRIM state.  get_msg_ns_from_origin is called
early, during the SET_BOUNDS_NS_FROM_ORIGIN state.  So in
get_msg_ns_from_origin, we can't assume that messages we encounter have
them.

[1] Like the trace from
    https://lists.lttng.org/pipermail/lttng-dev/2021-May/029955.html

Change-Id: Ie56b3250829197eadb823b7ac5d23efc46d12b3c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5689
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/utils/trimmer/trimmer.c

index 5b3a6c35d2c2918b4b4e47b9bb8c96f64427221d..a65b2ecc881fcd5928e969a353a35bae9a3f58bb 100644 (file)
@@ -784,27 +784,33 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin,
                        msg);
                break;
        case BT_MESSAGE_TYPE_PACKET_BEGINNING:
-               clock_class =
-                       bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
-                               msg);
-               if (G_UNLIKELY(!clock_class)) {
-                       goto error;
+       {
+               const bt_packet *packet = bt_message_packet_beginning_borrow_packet_const(msg);
+               const bt_stream *stream = bt_packet_borrow_stream_const(packet);
+               const bt_stream_class *stream_class = bt_stream_borrow_class_const(stream);
+
+               if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(stream_class)) {
+                       goto no_clock_snapshot;
                }
 
                clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
                        msg);
                break;
+       }
        case BT_MESSAGE_TYPE_PACKET_END:
-               clock_class =
-                       bt_message_packet_end_borrow_stream_class_default_clock_class_const(
-                               msg);
-               if (G_UNLIKELY(!clock_class)) {
-                       goto error;
+       {
+               const bt_packet *packet = bt_message_packet_end_borrow_packet_const(msg);
+               const bt_stream *stream = bt_packet_borrow_stream_const(packet);
+               const bt_stream_class *stream_class = bt_stream_borrow_class_const(stream);
+
+               if (!bt_stream_class_packets_have_end_default_clock_snapshot(stream_class)) {
+                       goto no_clock_snapshot;
                }
 
                clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const(
                        msg);
                break;
+       }
        case BT_MESSAGE_TYPE_STREAM_BEGINNING:
        {
                enum bt_message_stream_clock_snapshot_state cs_state;
@@ -840,27 +846,31 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin,
                break;
        }
        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
-               clock_class =
-                       bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
-                               msg);
-               if (G_UNLIKELY(!clock_class)) {
-                       goto error;
+       {
+               const bt_stream *stream = bt_message_discarded_events_borrow_stream_const(msg);
+               const bt_stream_class *stream_class = bt_stream_borrow_class_const(stream);
+
+               if (!bt_stream_class_discarded_events_have_default_clock_snapshots(stream_class)) {
+                       goto no_clock_snapshot;
                }
 
                clock_snapshot = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
                        msg);
                break;
+       }
        case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
-               clock_class =
-                       bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
-                               msg);
-               if (G_UNLIKELY(!clock_class)) {
-                       goto error;
+       {
+               const bt_stream *stream = bt_message_discarded_packets_borrow_stream_const(msg);
+               const bt_stream_class *stream_class = bt_stream_borrow_class_const(stream);
+
+               if (!bt_stream_class_discarded_packets_have_default_clock_snapshots(stream_class)) {
+                       goto no_clock_snapshot;
                }
 
                clock_snapshot = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
                        msg);
                break;
+       }
        case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
                clock_snapshot =
                        bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
This page took 0.027412 seconds and 4 git commands to generate.