src.ctf.fs: error out when failing to create index
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 17 Oct 2019 19:52:07 +0000 (15:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 21 Oct 2019 20:53:29 +0000 (16:53 -0400)
commit29a8227a1b5d08e0b600a2575372a3b5ae232d21
treeced5d0a61da7e93f09c4a044491fa6e9653baf29
parent401b70220ef76fa7b420f6c6d55c2d5bdecb931c
src.ctf.fs: error out when failing to create index

This patch makes src.ctf.fs fail if it is not able to build an index for
a data stream file.  This is generally a sign of a corrupted trace.

The plan is to be strict by default (abort if we find the trace looks
corrupted), but to later introduce a parameter to tell the component to
make those checks not fatal.

So for now, we can assume that the index will always be present, hence
the comment change in fs.h.

Without this patch, the trace provided as a test leads to this abort:

    10-17 15:59:00.749 14522 14522 W PLUGIN/SRC.CTF.FS/DS build_index_from_idx_file@data-stream-file.c:462 [auto-disc-source-ctf-fs] Invalid LTTng trace index file; indexed size != stream file size: file-size=16699392, total-packets-size=16896000
    10-17 15:59:00.749 14522 14522 W PLUGIN/SRC.CTF.FS/DS build_index_from_stream_file@data-stream-file.c:596 [auto-disc-source-ctf-fs] Invalid packet size reported in file: stream="/tmp/single/ch-1_17", packet-offset=12701696, packet-size-bytes=4194304, file-size=16699392
    10-17 15:59:00.749 14522 14522 W PLUGIN/SRC.CTF.FS add_ds_file_to_ds_file_group@fs.c:789 [auto-disc-source-ctf-fs] Failed to index CTF stream file '/tmp/single/ch-1_17'

     (╯°□°)╯︵ ┻━┻  /home/smarchi/src/babeltrace/src/plugins/ctf/fs-src/fs.c:1572: fix_index_lttng_event_after_packet_bug(): Assertion `index` failed.
    [1]    14522 abort      ./src/cli/babeltrace2 /tmp/single

The reason is that the index fails to build (the cumulative packet sizes
is larger than the data stream file size), but we keep going anyway.
The fix_index_lttng_event_after_packet_bug function, expecting an index
to always be present, hits that assert.

I added the problematic trace to our test trace collection, and a new
test script "test_fail" to test how the src.ctf.fs component class
handles invalid traces.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I5320102352eb8ef5004f0555dec2cc2736297a4f
src/plugins/ctf/fs-src/fs.c
src/plugins/ctf/fs-src/fs.h
tests/Makefile.am
tests/data/ctf-traces/fail/invalid-packet-size/README [new file with mode: 0644]
tests/data/ctf-traces/fail/invalid-packet-size/trace/channel0_3 [new file with mode: 0644]
tests/data/ctf-traces/fail/invalid-packet-size/trace/index/channel0_3.idx [new file with mode: 0644]
tests/data/ctf-traces/fail/invalid-packet-size/trace/metadata [new file with mode: 0644]
tests/plugins/src.ctf.fs/Makefile.am
tests/plugins/src.ctf.fs/fail/test_fail [new file with mode: 0755]
This page took 0.025123 seconds and 4 git commands to generate.