lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
* [lttng-dev] Babeltrace trimmer segfaults on custom trace
@ 2021-05-04 14:21 Dimitri Scheftelowitsch via lttng-dev
  2021-05-05  1:57 ` Simon Marchi via lttng-dev
  0 siblings, 1 reply; 4+ messages in thread
From: Dimitri Scheftelowitsch via lttng-dev @ 2021-05-04 14:21 UTC (permalink / raw)
  To: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 1678 bytes --]

Hi,

as mentioned on the IRC channel, babeltrace2 (both HEAD and current release
in the lttng Ubuntu 20 repo) aborts with a violated precondition in
`bt_clock_snapshot_get_ns_from_origin` on some custom traces we created.
One of these traces is attached. It seems that the offending message is of
type `BT_MESSAGE_TYPE_PACKET_BEGINNING`. What is confusing is that the
pretty-printer does not seem to be influenced by this, and furthermore, I
am not sure that this type of message actually requires a timestamp (at
least if I understood the CTF spec correctly). Is this an issue with the
trace itself or rather with babeltrace2?

To reproduce: `babeltrace2 nvctf
--timerange="17:09:13.034123470,17:29:18.034216302"`.

Any help would be appreciated.

Kind regards
Dimitri

-- 
Dimitri Scheftelowitsch
Software Engineer
ESR Labs GmbH
Phone +49 151 440 36 396
E-mail: dimitri.scheftelowitsch@esrlabs.com
www.esrlabs.com

-- 
*ESR Labs GmbH*
*Sitz der Gesellschaft:* Balanstr. 73, Haus 11, 4. OG, 
81541 München

*Geschäftsführer: *Wolfgang Köcher, Gerd Schäfer

Amtsgericht* *München, HRB 257919, USt-ID: DE282185835



This message 
(including any attachments) contains confidential information intended for 
a specific individual or entity as the intended recipient. If you are not 
the intended recipient, you are hereby notified that any distribution, any 
copying of this message in part or in whole, or any taking of action based 
on it, is strictly prohibited by law and may cause liability. In case you 
have received this message due to an error in transmission, we ask you to 
notify the sender immediately.




[-- Attachment #1.2: Type: text/html, Size: 3581 bytes --]

[-- Attachment #2: nvctf.zip --]
[-- Type: application/zip, Size: 24553 bytes --]

[-- Attachment #3: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [lttng-dev] Babeltrace trimmer segfaults on custom trace
  2021-05-04 14:21 [lttng-dev] Babeltrace trimmer segfaults on custom trace Dimitri Scheftelowitsch via lttng-dev
@ 2021-05-05  1:57 ` Simon Marchi via lttng-dev
  2021-05-05 13:45   ` Simon Marchi via lttng-dev
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi via lttng-dev @ 2021-05-05  1:57 UTC (permalink / raw)
  To: Dimitri Scheftelowitsch, lttng-dev

On 2021-05-04 10:21 a.m., Dimitri Scheftelowitsch via lttng-dev wrote:
> 
> Hi,
> 
> as mentioned on the IRC channel, babeltrace2 (both HEAD and current release in the lttng Ubuntu 20 repo) aborts with a violated precondition in `bt_clock_snapshot_get_ns_from_origin` on some custom traces we created. One of these traces is attached. It seems that the offending message is of type `BT_MESSAGE_TYPE_PACKET_BEGINNING`. What is confusing is that the pretty-printer does not seem to be influenced by this, and furthermore, I am not sure that this type of message actually requires a timestamp (at least if I understood the CTF spec correctly). Is this an issue with the trace itself or rather with babeltrace2?
> 
> To reproduce: `babeltrace2 nvctf --timerange="17:09:13.034123470,17:29:18.034216302"`.
> 
> Any help would be appreciated.

Hi Dimitri,

Thanks for providing a trace, the issue was very easy to reproduce.

There are indeed some missing checks in the trimmer code and the lib
code to avoid hitting some asserts when dealing with packets that have
no timestamps (clock snapshots).  I have a beginning of a patch here:

  https://review.lttng.org/c/babeltrace/+/5677

However, once that is fixed, I hit:

  https://github.com/efficios/babeltrace/blob/534d93a8b2ba86f56dfdf6aa7a10911da5f6432c/src/plugins/utils/trimmer/trimmer.c#L1284-L1290

If the trace has packets, the trimmer component currently requires
packets to have timestamps.   It would be possible for the trimmer to
support packet messages without timestamps, but support for it is not
implemented right now.  I tried to see if it would be possible for you
to just not use packets, but unfortunately I stumbled on what looks like
a bug in the CTF metadata parser, it hardcodes whether streams classes
have packets to true:

  https://github.com/efficios/babeltrace/blob/534d93a8b2ba86f56dfdf6aa7a10911da5f6432c/src/plugins/ctf/common/metadata/ctf-meta-translate.c#L576

So when I tried removing the packet from your trace, trimmer was still
unhappy about it.

The easiest immediate fix for you would probably be to add some
timestamps to your packets.  Looking at an LTTng trace, we can see:

struct packet_context {
        uint64_clock_monotonic_t timestamp_begin;
        uint64_clock_monotonic_t timestamp_end;
        uint64_t content_size;
        uint64_t packet_size;
        uint64_t packet_seq_num;
        unsigned long events_discarded;
        uint32_t cpu_id;
};

and

stream {
        id = 0;
        event.header := struct event_header_large;
        packet.context := struct packet_context;
};

So you can try adding a packet context with the two "timestamp" fields.
Just make sure that timestamp_begin is <= your first event's timestamp
and timestamp_end is >= your last event's timestamp.

And of course, the other option is to fix Babeltrace, if you have some
cycles to spare.

Simon
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [lttng-dev] Babeltrace trimmer segfaults on custom trace
  2021-05-05  1:57 ` Simon Marchi via lttng-dev
@ 2021-05-05 13:45   ` Simon Marchi via lttng-dev
  2021-05-20  8:34     ` [lttng-dev] [External] " Dimitri Scheftelowitsch via lttng-dev
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi via lttng-dev @ 2021-05-05 13:45 UTC (permalink / raw)
  To: Dimitri Scheftelowitsch, lttng-dev

On 2021-05-04 9:57 p.m., Simon Marchi via lttng-dev wrote:
> I tried to see if it would be possible for you
> to just not use packets, but unfortunately I stumbled on what looks like
> a bug in the CTF metadata parser, it hardcodes whether streams classes
> have packets to true:
> 
>   https://github.com/efficios/babeltrace/blob/534d93a8b2ba86f56dfdf6aa7a10911da5f6432c/src/plugins/ctf/common/metadata/ctf-meta-translate.c#L576

Hi Dimitri,

After talking with Philippe (Babeltrace 2's main contributor), this is
not a bug in the CTF metadata parser.  According to [1]:

    If the packet size field is missing, the whole stream only contains a single packet. 

So when if you don't have a packet header/context at all, the trace is
considered to have a single big packet.  That's why the metadata parser
always create streams with packets.

But the suggestion of adding timestamps to your packet is still valid.

Simon

[1] https://diamon.org/ctf/#spec5.2
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [lttng-dev] [External] Re: Babeltrace trimmer segfaults on custom trace
  2021-05-05 13:45   ` Simon Marchi via lttng-dev
@ 2021-05-20  8:34     ` Dimitri Scheftelowitsch via lttng-dev
  0 siblings, 0 replies; 4+ messages in thread
From: Dimitri Scheftelowitsch via lttng-dev @ 2021-05-20  8:34 UTC (permalink / raw)
  To: lttng-dev

Hi Simon,

thanks, that helped! Adding a packet context with timestamps solved the problem.

Kind regards,
Dimitri

-- 
*ESR Labs GmbH*
*Sitz der Gesellschaft:* Balanstr. 73, Haus 11, 4. OG, 
81541 München

*Geschäftsführer: *Wolfgang Köcher, Gerd Schäfer

Amtsgericht* *München, HRB 257919, USt-ID: DE282185835



This message 
(including any attachments) contains confidential information intended for 
a specific individual or entity as the intended recipient. If you are not 
the intended recipient, you are hereby notified that any distribution, any 
copying of this message in part or in whole, or any taking of action based 
on it, is strictly prohibited by law and may cause liability. In case you 
have received this message due to an error in transmission, we ask you to 
notify the sender immediately.



_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-20  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 14:21 [lttng-dev] Babeltrace trimmer segfaults on custom trace Dimitri Scheftelowitsch via lttng-dev
2021-05-05  1:57 ` Simon Marchi via lttng-dev
2021-05-05 13:45   ` Simon Marchi via lttng-dev
2021-05-20  8:34     ` [lttng-dev] [External] " Dimitri Scheftelowitsch via lttng-dev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).