Project

General

Profile

Actions

Bug #1364

open

CTF: Mismatching variant and tag selector and field names causes a crash

Added by Jérémie Galarneau almost 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
src.ctf.fs
Start date:
11/25/2022
Due date:
% Done:

0%

Estimated time:

Description

Running 200e2a8d2, decoding a CTF trace that has mismatching variant field and enumeration mapping names results in a crash:

❯ babeltrace ~/lttng-traces/auto-20221125-164416/ust/uid/1000/64-bit

 (╯°□°)╯︵ ┻━┻  ctf-meta-translate.cpp:276: ctf_field_class_variant_to_ir(): Assertion `mapping` failed.
[1]    215518 IOT instruction (core dumped)  babeltrace ~/lttng-traces/auto-20221125-164416/ust/uid/1000/64-bit
#0  0x00007fc99129964c in ?? () from /usr/lib/libc.so.6
#1  0x00007fc991249958 in raise () from /usr/lib/libc.so.6
#2  0x00007fc99123353d in abort () from /usr/lib/libc.so.6
#3  0x00007fc990ec3bf5 in bt_common_abort () at common.c:2111
#4  0x00007fc990f1d298 in bt_common_assert_failed (file=0x7fc990f28fbb "ctf-meta-translate.cpp", 
    line=276, func=0x7fc990f290e8 "ctf_field_class_variant_to_ir", 
    assertion=0x7fc990f2913f "mapping") at assert.c:40
#5  0x00007fc990ed1612 in ctf_field_class_variant_to_ir (fc=0x55568bfbf780, ctx=0x7ffd71c5f7f0)
    at ctf-meta-translate.cpp:276
#6  ctf_field_class_to_ir (ctx=ctx@entry=0x7ffd71c5f7f0, fc=0x55568bfbf780)
    at ctf-meta-translate.cpp:390
#7  0x00007fc990ed1883 in translate_struct_field_class_members (with_header_prefix=<optimized out>, 
    context_fc=<optimized out>, ir_fc=<optimized out>, fc=<optimized out>, ctx=<optimized out>)
    at ctf-meta-translate.cpp:159
#8  ctf_field_class_struct_to_ir (fc=0x55568bf13490, ctx=0x7ffd71c5f7f0)
    at ctf-meta-translate.cpp:173
#9  ctf_field_class_to_ir (ctx=ctx@entry=0x7ffd71c5f7f0, fc=0x55568bf13490)
    at ctf-meta-translate.cpp:381
#10 0x00007fc990ed2464 in scope_ctf_field_class_to_ir (ctx=0x7ffd71c5f7f0)
    at ctf-meta-translate.cpp:453
#11 ctf_stream_class_to_ir (ctx=0x7ffd71c5f7f0) at ctf-meta-translate.cpp:552
#12 ctf_trace_class_translate (self_comp=<optimized out>, ir_tc=<optimized out>, tc=0x55568bf14150)
    at ctf-meta-translate.cpp:641
#13 0x00007fc990eec028 in ctf_visitor_generate_ir_visit_node (ctx=0x55568bf3a620, 
    node=0x55568bf14040) at visitor-generate-ir.cpp:4776
#14 0x00007fc990ed965a in ctf_metadata_decoder_append_content (mdec=0x55568bf0b340, 
    fp=<optimized out>) at decoder.cpp:326
#15 0x00007fc990f0caaa in ctf_fs_metadata_set_trace_class (self_comp=self_comp@entry=0x55568bf13970, 
    ctf_fs_trace=ctf_fs_trace@entry=0x55568bf09da0, config=config@entry=0x55568bf0b478)
    at metadata.cpp:103
#16 0x00007fc990f098b8 in ctf_fs_trace_create (log_level=BT_LOGGING_LEVEL_WARNING, 
    metadata_config=0x55568bf0b478, name=0x0, 
    path=0x55568bf0b4a0 "/home/jgalar/lttng-traces/auto-20221125-164416/ust/uid/1000/64-bit", 
    self_comp_class=0x0, self_comp=0x55568bf13970) at fs.cpp:1027
#17 ctf_fs_component_create_ctf_fs_trace_one_path (self_comp_class=0x0, self_comp=0x55568bf13970, 
    traces=0x55568bf35620, trace_name=0x0, path_param=<optimized out>, ctf_fs=0x55568bf0b460)
    at fs.cpp:1129
#18 ctf_fs_component_create_ctf_fs_trace (ctf_fs=ctf_fs@entry=0x55568bf0b460, 
    paths_value=<optimized out>, trace_name_value=<optimized out>, 
    self_comp=self_comp@entry=0x55568bf13970, self_comp_class=self_comp_class@entry=0x0)
    at fs.cpp:2002
#19 0x00007fc990f0c3c3 in ctf_fs_create (self_comp_src=0x55568bf13970, params=0x55568bf0d9a0)
    at fs.cpp:2278
#20 ctf_fs_init (self_comp_src=0x55568bf13970, config=config@entry=0x0, 
    params=params@entry=0x55568bf0d9a0, init_method_data=init_method_data@entry=0x0) at fs.cpp:2311
#21 0x00007fc991568b4d in add_component_with_init_method_data (graph=graph@entry=0x55568bf13800, 
    comp_cls=comp_cls@entry=0x55568bf32970, 
    init_method=0x7fc990f0c320 <ctf_fs_init(bt_self_component_source*, bt_self_component_source_configuration*, bt_value const*, void*)>, name=name@entry=0x55568bf0d910 "auto-disc-source-ctf-fs", 
    params=params@entry=0x55568bf0d9a0, init_method_data=init_method_data@entry=0x0, 
    log_level=BT_LOGGING_LEVEL_WARNING, user_component=0x7ffd71c5fd00, 
    api_func=0x7fc9915a9660 <__func__.13> "bt_graph_add_source_component", 
    init_method_name=0x7fc9915aa860 "bt_component_class_source_initialize_method") at graph.c:1048
#22 0x00007fc99156aaae in add_source_component_with_initialize_method_data (
    api_func=0x7fc9915a9660 <__func__.13> "bt_graph_add_source_component", component=0x7ffd71c5fd00, 
    log_level=BT_LOGGING_LEVEL_WARNING, init_method_data=0x0, params=0x55568bf0d9a0, 
    name=0x55568bf0d910 "auto-disc-source-ctf-fs", comp_cls=0x55568bf32970, graph=0x55568bf13800)
    at graph.c:1127
#23 bt_graph_add_source_component (graph=0x55568bf13800, comp_cls=comp_cls@entry=0x55568bf32970, 
    name=0x55568bf0d910 "auto-disc-source-ctf-fs", params=0x55568bf0d9a0, 
    log_level=BT_LOGGING_LEVEL_WARNING, component=component@entry=0x7ffd71c5fd00) at graph.c:1152
#24 0x000055568aa845d6 in cmd_run_ctx_create_components_from_config_components (
    ctx=ctx@entry=0x7ffd71c5fde0, cfg_components=<optimized out>) at babeltrace2.c:2259
#25 0x000055568aa7ffe4 in cmd_run_ctx_create_components (ctx=0x7ffd71c5fde0) at babeltrace2.c:2355
#26 cmd_run (cfg=0x55568bf14390) at babeltrace2.c:2469
--Type <RET> for more, q to quit, c to continue without paging--
#27 main (argc=<optimized out>, argv=<optimized out>) at babeltrace2.c:2679

The relevant part of the trace's metadata is as-follows where you can see "_none" and "none" don't match.

        event.context := struct {
                enum : integer { size = 8; align = 8; signed = true; } {
                        "none" = 0,
                        "_int8" = 1,
                        "_int16" = 2,
                        "_int32" = 3,
                        "_int64" = 4,
                        "_uint8" = 5,
                        "_uint16" = 6,
                        "_uint32" = 7,
                        "_uint64" = 8,
                        "_float" = 9,
                        "_double" = 10,
                        "_string" = 11
                } __app_lol_gooo_tag;
                variant <__app_lol_gooo_tag> {
                        struct {} _none;
                        integer { size = 8; align = 8; signed = true; } _int8;
                        integer { size = 16; align = 8; signed = true; } _int16;
                        integer { size = 32; align = 8; signed = true; } _int32;
                        integer { size = 64; align = 8; signed = true; } _int64;
                        integer { size = 8; align = 8; } _uint8;
                        integer { size = 16; align = 8; } _uint16;
                        integer { size = 32; align = 8; } _uint32;
                        integer { size = 64; align = 8; } _uint64;
                        floating_point { align = 8; mant_dig = 24; exp_dig = 8; } _float;
                        floating_point { align = 8; mant_dig = 53; exp_dig = 11; } _double;
                        string _string;
                } __app_lol_gooo;
        };

Arguably, the CTF 1.8.3 specification says that:

Each variant type selector possess a field name, which is a unique identifier within the variant. The identifier is not allowed to use any reserved keyword. Replacing reserved keywords with underscore-prefixed field names is recommended. Fields starting with an underscore should have their leading underscore removed by the CTF trace readers.

As the term "should" is used, this presumably means that the reader could choose to match those or not. I can confirm that Babeltrace 1.5 also fails (but doesn't crash) so it seems reasonable to require an exact match.

I'm joining a trace that reproduces the issue.


Files

trace.tar.gz (3.75 MB) trace.tar.gz Jérémie Galarneau, 11/25/2022 05:09 PM

No data to display

Actions

Also available in: Atom PDF