Fix: src.ctf.fs: Not resolving event common ctx
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 4 Aug 2021 15:19:14 +0000 (11:19 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 6 Aug 2021 13:16:08 +0000 (09:16 -0400)
commit524e73a1580c5c4dac9359177ba6da2577424642
treeff4aaa92daf92a7b1f3eba2d018993a8aa751d38
parentdc0e9f45e1b68fdc9e19de17bee72c5f2676f5b0
Fix: src.ctf.fs: Not resolving event common ctx

Issue
=====
An assertion fails when creating the trace class with a sequence in the
event common context with the following callstack:
  #0  0x00007ffff7bf118b in raise () from /lib/x86_64-linux-gnu/libc.so.6
  #1  0x00007ffff7bd0859 in abort () from /lib/x86_64-linux-gnu/libc.so.6
  #2  0x00007ffff73e2d86 in bt_common_abort () at common.c:2111
  #3  0x00007ffff73ddec4 in bt_common_assert_failed (file=0x7ffff73ec268 "ctf-meta-update-value-storing-indexes.c", line=57, func=0x7ffff73ec300 <__func__.16976> "update_field_class_stored_value_index", assertion=0x7ffff73ec260 "tgt_fc") at assert.c:40
  #4  0x00007ffff738a396 in update_field_class_stored_value_index (fc=0x5555555d9c00, tc=0x555555598000, sc=0x555555598690, ec=0x0) at ctf-meta-update-value-storing-indexes.c:57
  #5  0x00007ffff738a4a0 in update_field_class_stored_value_index (fc=0x5555555d8ee0, tc=0x555555598000, sc=0x555555598690, ec=0x0) at ctf-meta-update-value-storing-indexes.c:81
  #6  0x00007ffff738a63b in ctf_trace_class_update_value_storing_indexes (ctf_tc=0x555555598000) at ctf-meta-update-value-storing-indexes.c:148
  #7  0x00007ffff73a0e95 in ctf_visitor_generate_ir_visit_node (visitor=0x55555559ce60, node=0x5555555ad100) at visitor-generate-ir.c:4900
  #8  0x00007ffff738e583 in ctf_metadata_decoder_append_content (mdec=0x55555559f380, fp=0x5555555aba00) at decoder.c:316
  #9  0x00007ffff73c9fda in ctf_fs_metadata_set_trace_class (self_comp=0x5555555a21b0, ctf_fs_trace=0x5555555981d0, config=0x55555559ee08) at metadata.c:107
  #10 0x00007ffff73c5e2f in ctf_fs_trace_create (self_comp=0x5555555a21b0, self_comp_class=0x0, path=0x555555597d40 "/home/frdeso/lttng-traces/auto-20210804-093702/kernel", name=0x0, metadata_config=0x55555559ee08, log_level=BT_LOGGING_LEVEL_WARNING) at fs.c:1072
  #11 0x00007ffff73c65cc in ctf_fs_component_create_ctf_fs_trace_one_path (ctf_fs=0x55555559edf0, path_param=0x5555555a1e50 "/home/frdeso/lttng-traces/auto-20210804-093702/kernel", trace_name=0x0, traces=0x555555597a80, self_comp=0x5555555a21b0, self_comp_class=0x0) at fs.c:1183
  #12 0x00007ffff73c8a4d in ctf_fs_component_create_ctf_fs_trace (ctf_fs=0x55555559edf0, paths_value=0x5555555ac4d0, trace_name_value=0x0, self_comp=0x5555555a21b0, self_comp_class=0x0) at fs.c:2097
  #13 0x00007ffff73c9a97 in ctf_fs_create (params=0x5555555abf70, self_comp_src=0x5555555a21b0) at fs.c:2397
  #14 0x00007ffff73c9b52 in ctf_fs_init (self_comp_src=0x5555555a21b0, config=0x0, params=0x5555555abf70, init_method_data=0x0) at fs.c:2431
  #15 0x00007ffff7f20b60 in add_component_with_init_method_data (graph=0x5555555a20a0, comp_cls=0x5555555a9580, init_method=0x7ffff73c9b1c <ctf_fs_init>, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, init_method_data=0x0, log_level=BT_LOGGING_LEVEL_WARNING, user_component=0x7fffffffe308, api_func=0x7ffff7f63880 <__func__.17336> "bt_graph_add_source_component", init_method_name=0x7ffff7f633a8 "bt_component_class_source_initialize_method") at graph.c:1048
  #16 0x00007ffff7f20e3d in add_source_component_with_initialize_method_data (graph=0x5555555a20a0, comp_cls=0x5555555a9580, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, init_method_data=0x0, log_level=BT_LOGGING_LEVEL_WARNING, component=0x7fffffffe308, api_func=0x7ffff7f63880 <__func__.17336> "bt_graph_add_source_component") at graph.c:1127
  #17 0x00007ffff7f20eec in bt_graph_add_source_component (graph=0x5555555a20a0, comp_cls=0x5555555a9580, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, log_level=BT_LOGGING_LEVEL_WARNING, component=0x7fffffffe308) at graph.c:1152
  #18 0x000055555556251a in cmd_run_ctx_create_components_from_config_components (ctx=0x7fffffffe390, cfg_components=0x5555555ab0c0) at babeltrace2.c:2252
  #19 0x00005555555628ec in cmd_run_ctx_create_components (ctx=0x7fffffffe390) at babeltrace2.c:2347
  #20 0x0000555555562cb5 in cmd_run (cfg=0x5555555a1b80) at babeltrace2.c:2461
  #21 0x00005555555635ef in main (argc=2, argv=0x7fffffffe508) at babeltrace2.c:2673

This is due to the fact that the event context field class containing a
sequence is never resolved by calling `resolve_root_class()`. This leads
to the `ctf_field_class_sequence::length_fc` field never being
initialized.

Looking at the `resolve_stream_class_field_classes()` function, it looks
like there is a typo where the `CTF_SCOPE_EVENT_SPECIFIC_CONTEXT` enum
label was used where the intention was to use
`CTF_SCOPE_EVENT_COMMON_CONTEXT` according to the surrounding code.

Fix
===
Replace `CTF_SCOPE_EVENT_SPECIFIC_CONTEXT` by `CTF_SCOPE_EVENT_COMMON_CONTEXT`.

Test
====
This commit adds a minimal testcase with a sequence in the event and
packet contexts.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I370a620855f2dcdf51d02db80b9df22b0f043f3a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6257
CI-Build: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/common/metadata/ctf-meta-resolve.c
tests/cli/test_trace_copy
tests/data/ctf-traces/succeed/meta-ctx-sequence/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/meta-ctx-sequence/stream [new file with mode: 0644]
tests/data/plugins/src.ctf.fs/succeed/trace-meta-ctx-sequence.expect [new file with mode: 0644]
tests/plugins/src.ctf.fs/succeed/test_succeed
This page took 0.027414 seconds and 4 git commands to generate.