Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix:
ctf
plugin: use element FC's alignment as array/seq. FC alignment
Observed issue ============== When reading some CTF trace with an empty array/sequence field, Babeltrace 2 can fail. More specifically, for the trace `tests/data/ctf-traces/succeed/array-align-elem` (added by this patch): The CLI's output is: 07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER [email protected]:535 [auto-disc-source-ctf-fs] User function returned EOF, but message iterator is in an unexpected state: state=DSCOPE_EVENT_PAYLOAD_CONTINUE, cur-packet-size=-1, cur=24, packet-cur=24, last-eh-at=16 07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER [email protected]:632 [auto-disc-source-ctf-fs] Cannot ensure that buffer has at least one byte: msg-addr=0x55d3b4e051f0, status=ERROR 07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER [email protected]:2881 [auto-disc-source-ctf-fs] Cannot handle state: msg-it-addr=0x55d3b4e051f0, state=DSCOPE_EVENT_PAYLOAD_CONTINUE 07-21 14:00:24.636 73959 73959 E PLUGIN/SRC.CTF.FS [email protected]:90 [auto-disc-source-ctf-fs] Failed to get next message from CTF message iterator. 07-21 14:00:24.636 73959 73959 W LIB/MSG-ITER [email protected]:865 Component input port message iterator's "next" method failed: iter-addr=0x55d3b4e05000, iter-upstream-comp-name="auto-disc-source-ctf-fs", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=SOURCE, iter-upstream-comp-class-name="fs", iter-upstream-comp-class-partial-descr="Read CTF traces from the file sy", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="array-align-elem | 0 | array-align-elem/stream", status=ERROR 07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER [email protected]:446 [muxer] Upstream iterator's next method returned an error: status=ERROR 07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER [email protected]:989 [muxer] Cannot validate muxer's upstream message iterator wrapper: muxer-msg-iter-addr=0x55d3b4dcb830, muxer-upstream-msg-iter-wrap-addr=0x55d3b4e055c0 ev: { a = 1, b = [ ], c = 2 } 07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER [email protected]:1417 [muxer] Cannot get next message: comp-addr=0x55d3b4dcae70, muxer-comp-addr=0x55d3b4dcaef0, muxer-msg-iter-addr=0x55d3b4dcb830, msg-iter-addr=0x55d3b4dcb750, status=ERROR 07-21 14:00:24.636 73959 73959 W LIB/MSG-ITER [email protected]:865 Component input port message iterator's "next" method failed: iter-addr=0x55d3b4dcb750, iter-upstream-comp-name="muxer", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=FILTER, iter-upstream-comp-class-name="muxer", iter-upstream-comp-class-partial-descr="Sort messages from multiple inpu", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR 07-21 14:00:24.636 73959 73959 W LIB/GRAPH [email protected]:462 Component's "consume" method failed: status=ERROR, comp-addr=0x55d3b4dcb070, comp-name="pretty", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="pretty", comp-class-partial-descr="Pretty-print messages (`text` fo", comp-class-is-frozen=1, comp-class-so-handle-addr=0x55d3b4dc7c50, comp-class-so-handle-path="/home/eepp/dev/babeltrace/install/lib/babeltrace2/plugins/babeltrace-plugin-text.la", comp-input-port-count=1, comp-output-port-count=0 07-21 14:00:24.636 73959 73959 E CLI [email protected]:2529 Graph failed to complete successfully ERROR: [Babeltrace CLI] (babeltrace2.c:2529) Graph failed to complete successfully CAUSED BY [libbabeltrace2] (graph.c:462) Component's "consume" method failed: status=ERROR, comp-addr=0x55d3b4dcb070, comp-name="pretty", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="pretty", comp-class-partial-descr="Pretty-print messages (`text` fo", comp-class-is-frozen=1, comp-class-so-handle-addr=0x55d3b4dc7c50, comp-class-so-handle-path="/home/eepp/dev/babeltrace/install/lib/babeltrace2/plugins/babeltrace-plugin-text.la", comp-input-port-count=1, comp-output-port-count=0 CAUSED BY [libbabeltrace2] (iterator.c:865) Component input port message iterator's "next" method failed: iter-addr=0x55d3b4dcb750, iter-upstream-comp-name="muxer", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=FILTER, iter-upstream-comp-class-name="muxer", iter-upstream-comp-class-partial-descr="Sort messages from multiple inpu", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:1417) Cannot get next message: comp-addr=0x55d3b4dcae70, muxer-comp-addr=0x55d3b4dcaef0, muxer-msg-iter-addr=0x55d3b4dcb830, msg-iter-addr=0x55d3b4dcb750, status=ERROR CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:989) Cannot validate muxer's upstream message iterator wrapper: muxer-msg-iter-addr=0x55d3b4dcb830, muxer-upstream-msg-iter-wrap-addr=0x55d3b4e055c0 CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:446) Upstream iterator's next method returned an error: status=ERROR CAUSED BY [libbabeltrace2] (iterator.c:865) Component input port message iterator's "next" method failed: iter-addr=0x55d3b4e05000, iter-upstream-c Cause ===== The internal CTF IR array and sequence field classes do not have an alignment which is equal to their element FC's alignment, although CTF 1.8.3 requires it [1]: > Arrays are always aligned on their element alignment requirement. Solution ======== In `bfcr.c`, align_class_state() is already called for array/sequence fields. Add a CTF IR trace class visitor to set any array/sequence FC's alignment to its element FC's alignment, recursively (postorder). Also update, postorder, structure FC alignments since some of the alignments of the field types of their members can change. Note ==== This patch adds two minimalist CTF traces to test the fix as well as two new corresponding tests in `tests/plugins/src.ctf.fs/succeed/test_succeed`: `array-align-elem`: Metadata: struct { integer { size = 8; } a; integer { size = 8; align = 16; } b[0]; integer { size = 8; } c; }; Taking the aligment of `b` into account, there's one byte of padding between `a` and `c`: a # c ^---- alignment of `b` `struct-array-align-elem`: Metadata: struct { integer { size = 8; } x; struct { integer { size = 8; } a; integer { size = 8; align = 32; } b[0]; } y; integer { size = 8; } z; }; Taking the alignment of `y.b` into account, the `y` structure itself is 32-bit-aligned, making the outer structure also 32-bit-aligned. Therefore, there are three bytes of padding between `x` and `a`, and three other bytes of padding between `a` and `z`: x # # # a # # # z ^ ^-------- alignment of `b` '---------------- alignment of `y` References ========== [1]: https://diamon.org/ctf/v1.8.3/#spec4.2.3 Fixes: https://bugs.lttng.org/issues/1276 Signed-off-by: Philippe Proulx <[email protected]> Change-Id: I06b4fbeda9ffd5b87b4964dd567027d0bfd5e9c7 Reviewed-on: https://review.lttng.org/c/babeltrace/+/4056
- Loading branch information