Fix: src.ctf.fs: pointer arithmetics on non-adjacent memory
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 5 Jul 2019 15:19:32 +0000 (11:19 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 5 Jul 2019 16:56:28 +0000 (12:56 -0400)
commitde38c26a14b60cb3b6d31cc124c187e2c1816bf5
treebf945cdfef31a8ee6d7afc5bfeaed1e242468ffa
parentc211d9c0bd47b374497451a4fa6aa6b20ac4fa8b
Fix: src.ctf.fs: pointer arithmetics on non-adjacent memory

Issue
=====
When indexing a trace using `*.idx` files, if streams span more than one
packet the user may witness the following warning message:
  W PLUGIN/SRC.CTF.FS/DS build_index_from_idx_file@data-stream-file.c:400
    [source-ctf-fs] Invalid, non-monotonic, packet offset encountered in
    LTTng trace index file: previous offset=14757395258967641292, current offset=4096

This is caused by the fact the we're using pointer arithmetics to get
the pointer to the previous entry of an array. This ends returning
garbage because it's a pointer array and not a regular array storing the
objects as the code expects to.

This regression was most probably introduced by the following commit:
  commit 7ed5243afe12c7c12fa5305fff99b93ad23bbdff
  Author: Francis Deslauriers <francis.deslauriers@efficios.com>
  Date:   Wed May 15 14:59:10 2019 -0400

      src.ctf.fs: merge all indexes to the fs_ds_group level

This problematic commit changes the `entries` fields of the `struct
ctf_fs_ds_index` from a `GArray *` to `GPtrArray * without changing the
pointer arithmetics.

This was not an error because indexing using `*.idx` files is optional
and indexing may fail back to direct packet indexing.

Solution
========
Use a local variable to store a pointer to the previous index_entry
rather than using pointer arithmetics.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3e5608d0359be2a447e79415517068c64f5a2817
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1637
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/fs-src/data-stream-file.c
This page took 0.02607 seconds and 4 git commands to generate.