Fix: flt.utils.muxer: reject two different clock classes with unknown origin and...
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 12 Mar 2024 18:45:24 +0000 (14:45 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
When getting a message with a clock class whose origin is unknown and
that has no UUID, the expectation of a `flt.utils.muxer` component
should be that all subsequent messages with an associated clock class
will have the exact same clock class instance.  Currently, it accepts
any other clock class instance that has an unknown origin and no UUID.

This is a change that is equivalent to what was done in commit
29e191fceb61 ("Fix: lib: strengthen clock expectation check for no Unix
epoch / no UUID case") in the library iterator code.

When first seeing a clock class with unknown origin and no UUID, make
the muxer message iterator save the clock class instance, holding a
strong reference, and ensure that all clock classes seen after are the
same instance.

Change-Id: I676471cc0c3b88a83cd0b452dee8d6b1ed549e4d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12044
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/utils/muxer/msg-iter.cpp
src/plugins/utils/muxer/msg-iter.hpp

index 2121a0f222595687d4164226311163af024c3acd..63b08c2dd2e7d3eb630169bb6c701906d9c727cd 100644 (file)
@@ -280,6 +280,7 @@ void MsgIter::_setClkClsExpectation(
              * without a UUID.
              */
             _mClkClsExpectation = _ClkClsExpectation::ORIG_ISNT_UNIX_EPOCH_AND_NO_UUID;
+            _mExpectedClkCls = clkCls->shared();
         }
     }
 }
@@ -324,27 +325,22 @@ void MsgIter::_makeSureClkClsIsExpected(
         break;
     case _ClkClsExpectation::ORIG_ISNT_UNIX_EPOCH_AND_NO_UUID:
         BT_ASSERT_DBG(!_mExpectedClkClsUuid);
+        BT_ASSERT_DBG(_mExpectedClkCls);
 
-        if (clkCls->originIsUnixEpoch()) {
+        if (clkCls->libObjPtr() != _mExpectedClkCls->libObjPtr()) {
             BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
                 bt2::Error,
-                "Expecting a clock class not having a Unix epoch origin, "
-                "but got one having a Unix epoch origin: "
-                "clock-class-addr={}, clock-class-name={}",
+                "Unexpected clock class: "
+                "expected-clock-class-addr={}, expected-clock-class-name={}, "
+                "actual-clock-class-addr={}, actual-clock-class-name={}",
+                fmt::ptr(_mExpectedClkCls->libObjPtr()), optLogStr(_mExpectedClkCls->name()),
                 clkClsAddr, optLogStr(clkCls->name()));
         }
 
-        if (clkCls->uuid()) {
-            BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
-                bt2::Error,
-                "Expecting a clock class without a UUID, but got one with a UUID: "
-                "clock-class-addr={}, clock-class-name={}, uuid={}",
-                clkClsAddr, optLogStr(clkCls->name()), clkCls->uuid()->str());
-        }
-
         break;
     case _ClkClsExpectation::ORIG_ISNT_UNIX_EPOCH_AND_SPEC_UUID:
         BT_ASSERT_DBG(_mExpectedClkClsUuid);
+        BT_ASSERT_DBG(!_mExpectedClkCls);
 
         if (clkCls->originIsUnixEpoch()) {
             BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
index d6daefb48e226a8f2422147d491b5e62f973ee57..d8c33c3787bb1b6a38b210098498c053f25c2db6 100644 (file)
@@ -123,9 +123,13 @@ private:
      *
      * For `ORIG_ISNT_UNIX_EPOCH_AND_SPEC_UUID`, `*_mExpectedClkClsUuid`
      * is the expected specific UUID.
+     *
+     * For `ORIG_ISNT_UNIX_EPOCH_AND_NO_UUID`, `_mExpectedClkCls` is the
+     * expected clock class.
      */
     _ClkClsExpectation _mClkClsExpectation = _ClkClsExpectation::ANY;
     bt2s::optional<bt2c::Uuid> _mExpectedClkClsUuid;
+    bt2::ConstClockClass::Shared _mExpectedClkCls;
 };
 
 } /* namespace bt2mux */
This page took 0.025432 seconds and 4 git commands to generate.