Skip to content

Commit

Permalink
Fix: liblttng-ctl: leak of payload on field listing
Browse files Browse the repository at this point in the history
LeakSanitizer reports the following leak:

==974957==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fdb86fcd1b2 in __interceptor_realloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x7fdb86d7c296 in lttng_dynamic_buffer_set_capacity(lttng_dynamic_buffer*, unsigned long) /home/jgalar/EfficiOS/src/lttng-tools/src/common/dynamic-buffer.cpp:159
    #2 0x7fdb86d7c060 in lttng_dynamic_buffer_set_size(lttng_dynamic_buffer*, unsigned long) /home/jgalar/EfficiOS/src/lttng-tools/src/common/dynamic-buffer.cpp:112
    #3 0x7fdb86d2589a in recv_payload_sessiond /home/jgalar/EfficiOS/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.cpp:230
    #4 0x7fdb86d26fa5 in lttng_ctl_ask_sessiond_payload(lttng_payload_view*, lttng_payload*) /home/jgalar/EfficiOS/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.cpp:662
    lttng#5 0x7fdb86d2cd8d in lttng_list_tracepoint_fields /home/jgalar/EfficiOS/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.cpp:1767
    lttng#6 0x56481623cb4c in list_ust_event_fields commands/list.cpp:850
    lttng#7 0x5648162448d9 in cmd_list(int, char const**) commands/list.cpp:2394
    lttng#8 0x56481628fb3e in handle_command /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:238
    lttng#9 0x564816290601 in parse_args /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:427
    lttng#10 0x564816290908 in main /home/jgalar/EfficiOS/src/lttng-tools/src/bin/lttng/lttng.cpp:476
    lttng#11 0x7fdb8661730f in __libc_start_call_main (/usr/lib/libc.so.6+0x2d30f)

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).

The session daemon's reply is indeed never released in
lttng_list_tracepoint_fields.

Signed-off-by: Jérémie Galarneau <[email protected]>
Change-Id: Idd244b52a69f3b74e5c131c1c36c6ee6d76f4285
  • Loading branch information
jgalar committed Apr 14, 2022
1 parent f149493 commit 5c5c694
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/lttng-ctl/lttng-ctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,13 +1747,13 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
unsigned int nb_event_fields = 0;
struct lttng_payload reply;

lttng_payload_init(&reply);

if (handle == NULL) {
ret = -LTTNG_ERR_INVALID;
goto end;
}

lttng_payload_init(&reply);

memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTNG_LIST_TRACEPOINT_FIELDS;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
Expand Down Expand Up @@ -1807,6 +1807,7 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
ret = nb_event_fields;

end:
lttng_payload_reset(&reply);
return ret;
}

Expand Down

0 comments on commit 5c5c694

Please sign in to comment.