Fix: ctf: wrongfully requiring CTF metadata signature for every section
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 24 Feb 2022 21:48:33 +0000 (16:48 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 24 Feb 2022 23:23:50 +0000 (18:23 -0500)
Issue
=====
When testing the special live tracing session case of sending the
metadata in multiple batches, we witnessed the CTF metadata decoder
returning an error if the "/* CTF 1.8" signature is omitted from the
metadata sections following the first one.

Here is the output of Babeltrace when this error occurs:
07-22 12:18:38.518 539222 539222 W PLUGIN/CTF/META/DECODER ctf_metadata_decoder_append_content@decoder.c:242 [lttng-live] Missing "/* CTF major.minor" signature in plain text metadata file stream: mdec
-addr=0x2398ec0
07-22 12:18:38.518 539222 539222 E PLUGIN/CTF/META/DECODER ctf_metadata_decoder_append_content@decoder.c:251 [lttng-live] Invalid metadata version found in plain text signature: version=571641920.0, md
ec-addr=0x2398ec0

We expect the decoder to only require this signature when decoding the
first section of plain-text metadata.

Solution
========
Only check for the signature when processing the first metadata section.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3153abf58ade5f5b02362dbedde382f398f5ee4e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3807

src/plugins/ctf/common/metadata/decoder.cpp

index a45d7b03c3e23ab0add155eb1a329c4e97bd25bd..740cbf05e264b515de41f3cf7591cfc9e748b376 100644 (file)
@@ -41,6 +41,7 @@ struct ctf_metadata_decoder
     int bo;
     struct ctf_metadata_decoder_config config;
     struct meta_log_config log_cfg;
     int bo;
     struct ctf_metadata_decoder_config config;
     struct meta_log_config log_cfg;
+    bool has_checked_plaintext_signature;
 };
 
 struct packet_header
 };
 
 struct packet_header
@@ -221,7 +222,7 @@ ctf_metadata_decoder_append_content(struct ctf_metadata_decoder *mdec, FILE *fp)
             status = CTF_METADATA_DECODER_STATUS_ERROR;
             goto end;
         }
             status = CTF_METADATA_DECODER_STATUS_ERROR;
             goto end;
         }
-    } else {
+    } else if (!mdec->has_checked_plaintext_signature) {
         unsigned int major, minor;
         ssize_t nr_items;
         const long init_pos = ftell(fp);
         unsigned int major, minor;
         ssize_t nr_items;
         const long init_pos = ftell(fp);
@@ -263,6 +264,8 @@ ctf_metadata_decoder_append_content(struct ctf_metadata_decoder *mdec, FILE *fp)
             status = CTF_METADATA_DECODER_STATUS_ERROR;
             goto end;
         }
             status = CTF_METADATA_DECODER_STATUS_ERROR;
             goto end;
         }
+
+        mdec->has_checked_plaintext_signature = true;
     }
 
 #if YYDEBUG
     }
 
 #if YYDEBUG
This page took 0.04177 seconds and 4 git commands to generate.