Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak in opts #963

Closed
rls1004 opened this issue Oct 16, 2019 · 0 comments · Fixed by #964
Closed

memory leak in opts #963

rls1004 opened this issue Oct 16, 2019 · 0 comments · Fixed by #964

Comments

@rls1004
Copy link
Contributor

rls1004 commented Oct 16, 2019

steps to reproduce :

$ gcc -pg -g tests/s-signal.c
$ uftrace record --disable --signal SIGUSR1@trace_on a.out
uftrace: install signal handlers to task 85074

=================================================================
==85073==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x7fb2922a6f40 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdef40)
    #1 0x55667c92f3a7 in strjoin /home/rls1004/uftrace/utils/utils.c:544
    #2 0x55667c8a9d9f in opt_add_string /home/rls1004/uftrace/uftrace.c:228
    #3 0x55667c8ad5aa in parse_option /home/rls1004/uftrace/uftrace.c:806
    #4 0x7fb290c93d0d in argp_parse (/lib/x86_64-linux-gnu/libc.so.6+0x12fd0d)
    #5 0x55667c8afb8d in main /home/rls1004/uftrace/uftrace.c:1092
    #6 0x7fb290b85b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

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

opts->sig_trigger is allocated and not freed.

uftrace/uftrace.c

Lines 805 to 807 in 657d4be

case OPT_signal:
opts->sig_trigger = opt_add_string(opts->sig_trigger, arg);
break;

uftrace/uftrace.c

Lines 1014 to 1026 in 657d4be

static void free_opts(struct opts *opts)
{
free(opts->filter);
free(opts->trigger);
free(opts->sort_keys);
free(opts->args);
free(opts->retval);
free(opts->tid);
free(opts->event);
free(opts->patch);
free(opts->caller);
free(opts->watch);
}

rls1004 added a commit to rls1004/uftrace that referenced this issue Oct 16, 2019
Added code to free for opts->sig_trigger

Fixed: namhyung#963

Signed-off-by: MinJeong Kim <98nba@naver.com>
namhyung pushed a commit that referenced this issue Oct 17, 2019
Added code to free for opts->sig_trigger

Fixed: #963

Signed-off-by: MinJeong Kim <98nba@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants