Fix: lttng: add-trigger: leak of parser context on capture
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Apr 2022 03:43:10 +0000 (23:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Apr 2022 03:46:05 +0000 (23:46 -0400)
==1501334==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 16386 byte(s) in 1 object(s) allocated from:
    #0 0x7f95efc3cdd9 in __interceptor_malloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55acb0681ed3 in lttng_filter_yyalloc(unsigned long, void*) filter/filter-lexer.cpp:2511
    #2 0x55acb067f2f2 in lttng_filter_yy_create_buffer(_IO_FILE*, int, void*) filter/filter-lexer.cpp:1895
    #3 0x55acb067ea44 in yyrestart(_IO_FILE*, void*) filter/filter-lexer.cpp:1824
    #4 0x55acb0649a43 in filter_parser_ctx_alloc(_IO_FILE*) filter/filter-parser.ypp:271
    #5 0x55acb0649e7f in filter_parser_ctx_create_from_filter_expression(char const*, filter_parser_ctx**) filter/filter-parser.ypp:332
    #6 0x55acb058ee89 in parse_event_rule commands/add_trigger.cpp:783
    #7 0x55acb05920c0 in handle_condition_event commands/add_trigger.cpp:1361
    #8 0x55acb0592739 in parse_condition commands/add_trigger.cpp:1457
    #9 0x55acb0596b56 in cmd_add_trigger(int, char const**) commands/add_trigger.cpp:2304
    #10 0x55acb05a5b80 in handle_command /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:238
    #11 0x55acb05a6643 in parse_args /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:427
    #12 0x55acb05a694a in main /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:476
    #13 0x7f95ef28730f in __libc_start_call_main (/usr/lib/libc.so.6+0x2d30f)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6fa21e7d066e0cf48afc3f91ceefbfd19c6b86fd

src/bin/lttng/commands/add_trigger.cpp

index 4ae57638fc71491e982a166acefec2fce2970ce3..8619a822161eda44fbe2f61aceb7dedae8c07781 100644 (file)
@@ -789,6 +789,8 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv,
 
                                event_expr = ir_op_root_to_event_expr(
                                                parser_ctx->ir_root, arg);
+                               filter_parser_ctx_free(parser_ctx);
+                               parser_ctx = nullptr;
                                if (!event_expr) {
                                        /*
                                         * ir_op_root_to_event_expr has printed
This page took 0.026162 seconds and 4 git commands to generate.