Skip to content

Commit

Permalink
live: Fix memory leak in live replay
Browse files Browse the repository at this point in the history
This fixes a memory leak in live replay as follows:

  $ make ASAN=1 -j8
  $ ./uftrace -L. --no-pager t-abc
  # DURATION     TID     FUNCTION
     1.227 us [126865] | __monstartup();
     0.940 us [126865] | __cxa_atexit();
              [126865] | main() {
              [126865] |   a() {
              [126865] |     b() {
              [126865] |       c() {
     0.766 us [126865] |         getpid();
     1.791 us [126865] |       } /* c */
     2.281 us [126865] |     } /* b */
     2.714 us [126865] |   } /* a */
     3.200 us [126865] | } /* main */

  =================================================================
  ==126864==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 6 byte(s) in 1 object(s) allocated from:
      #0 0x7fdc57f5034f in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x6234f)
      #1 0x499e74 in __read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2160
      #2 0x49a1b0 in peek_rstack /home/honggyu/work/uftrace/utils/fstack.c:2230
      #3 0x445b5d in command_replay /home/honggyu/work/uftrace/cmds/replay.c:1163
      #4 0x438558 in command_live /home/honggyu/work/uftrace/cmds/live.c:158
      #5 0x40b6c2 in main /home/honggyu/work/uftrace/uftrace.c:1166
      #6 0x7fdc568d682f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Fixed: namhyung#940

Signed-off-by: Byeonggon Lee <[email protected]>
  • Loading branch information
binkoni authored and namhyung committed Oct 18, 2019
1 parent ff2f61e commit 745dbec
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions utils/fstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ static int __read_rstack(struct uftrace_data *handle,
if (task->rstack->addr == EVENT_ID_PERF_COMM) {
task->rstack->more = 1;
/* abuse task->args to save comm */
free(task->args.data);
task->args.data = xstrdup(perf->u.comm.comm);
task->args.len = strlen(perf->u.comm.comm);
}
Expand Down

0 comments on commit 745dbec

Please sign in to comment.