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

-mfentry and -mnop-mcount #6

Open
honggyukim opened this issue Mar 25, 2019 · 5 comments
Open

-mfentry and -mnop-mcount #6

honggyukim opened this issue Mar 25, 2019 · 5 comments

Comments

@honggyukim
Copy link
Owner

-mfentry
-mno-fentry

  • If profiling is active (-pg), put the profiling counter call before the prologue. Note: On x86 architectures the attribute "ms_hook_prologue" isn't possible at the moment for -mfentry and -pg.

-mrecord-mcount
-mno-record-mcount

  • If profiling is active (-pg), generate a __mcount_loc section that contains pointers to each profiling call. This is useful for automatically patching and out calls.

-mnop-mcount
-mno-nop-mcount

  • If profiling is active (-pg), generate the calls to the profiling functions as NOPs. This is useful when they should be patched in later dynamically. This is likely only useful together with -mrecord-mcount.
$ cd gcc/config
$ grep nop_mcount * -rIn
i386/i386.opt:929:Target Report Var(flag_nop_mcount)
i386/i386.c:4235:  if (flag_nop_mcount)
i386/i386.c:4238:  if (flag_nop_mcount && flag_pic)
i386/i386.c:41185:  if (flag_nop_mcount)
s390/s390.opt:298:Target Report Var(flag_nop_mcount)
s390/s390.c:12558:      if (flag_nop_mcount)
s390/s390.c:12568:      if (flag_nop_mcount)
s390/s390.c:12585:      if (flag_nop_mcount)
$ cat gcc/config/i386/i386.c
    ...
/* Print call to TARGET to FILE.  */

static void
x86_print_call_or_nop (FILE *file, const char *target)
{ 
  if (flag_nop_mcount)
    /* 5 byte nop: nopl 0(%[re]ax,%[re]ax,1) */
    fprintf (file, "1:" ASM_BYTE "0x0f, 0x1f, 0x44, 0x00, 0x00\n");
  else
    fprintf (file, "1:\tcall\t%s\n", target);
} 

/* Output assembler code to FILE to increment profiler label # LABELNO
   for profiling a function entry.  */
void
x86_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
{
  const char *mcount_name = (flag_fentry ? MCOUNT_NAME_BEFORE_PROLOGUE
                                         : MCOUNT_NAME);

  if (cfun->machine->endbr_queued_at_entrance)
    fprintf (file, "\t%s\n", TARGET_64BIT ? "endbr64" : "endbr32");

  if (TARGET_64BIT)
    {
#ifndef NO_PROFILE_COUNTERS
      fprintf (file, "\tleaq\t%sP%d(%%rip),%%r11\n", LPREFIX, labelno);
#endif

      if (!TARGET_PECOFF && flag_pic)
        fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n", mcount_name);
      else
        x86_print_call_or_nop (file, mcount_name);
    }
  else if (flag_pic)
    {
#ifndef NO_PROFILE_COUNTERS
      fprintf (file, "\tleal\t%sP%d@GOTOFF(%%ebx),%%" PROFILE_COUNT_REGISTER "\n",
               LPREFIX, labelno);
#endif
      fprintf (file, "1:\tcall\t*%s@GOT(%%ebx)\n", mcount_name);
    }
  else
    {
#ifndef NO_PROFILE_COUNTERS
      fprintf (file, "\tmovl\t$%sP%d,%%" PROFILE_COUNT_REGISTER "\n",
               LPREFIX, labelno);
#endif
      x86_print_call_or_nop (file, mcount_name);
    }

  if (flag_record_mcount)
    {
      fprintf (file, "\t.section __mcount_loc, \"a\",@progbits\n");
      fprintf (file, "\t.%s 1b\n", TARGET_64BIT ? "quad" : "long");
      fprintf (file, "\t.previous\n");
    }
}
    ...
@honggyukim
Copy link
Owner Author

honggyukim commented Mar 25, 2019

$ grep MCOUNT_NAME gcc/config/i386/*
    ...
config/i386/i386.h:#define MCOUNT_NAME "_mcount"
config/i386/i386.h:#define MCOUNT_NAME_BEFORE_PROLOGUE "__fentry__"
    ...
config/i386/x86-64.h:#undef MCOUNT_NAME
config/i386/x86-64.h:#define MCOUNT_NAME "mcount"

@honggyukim
Copy link
Owner Author

honggyukim commented Mar 25, 2019

$ cat gcc/config/arm/arm.h
    ...
/* Call the function profiler with a given profile label.  The Acorn
   compiler puts this BEFORE the prolog but gcc puts it afterwards.
   On the ARM the full profile code will look like:
        .data
        LP1
                .word   0
        .text
                mov     ip, lr
                bl      mcount
                .word   LP1

   profile_function() in final.c outputs the .data section, FUNCTION_PROFILER
   will output the .text section.

   The ``mov ip,lr'' seems like a good idea to stick with cc convention.
   ``prof'' doesn't seem to mind about this!

   Note - this version of the code is designed to work in both ARM and
   Thumb modes.  */
#ifndef ARM_FUNCTION_PROFILER
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO)          \
{                                                       \
  char temp[20];                                        \
  rtx sym;                                              \
                                                        \
  asm_fprintf (STREAM, "\tmov\t%r, %r\n\tbl\t",         \
           IP_REGNUM, LR_REGNUM);                       \
  assemble_name (STREAM, ARM_MCOUNT_NAME);              \
  fputc ('\n', STREAM);                                 \
  ASM_GENERATE_INTERNAL_LABEL (temp, "LP", LABELNO);    \
  sym = gen_rtx_SYMBOL_REF (Pmode, temp);               \
  assemble_aligned_integer (UNITS_PER_WORD, sym);       \
}
#endif

#ifdef THUMB_FUNCTION_PROFILER
#define FUNCTION_PROFILER(STREAM, LABELNO)              \
  if (TARGET_ARM)                                       \
    ARM_FUNCTION_PROFILER (STREAM, LABELNO)             \
  else                                                  \
    THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
#else
#define FUNCTION_PROFILER(STREAM, LABELNO)              \
    ARM_FUNCTION_PROFILER (STREAM, LABELNO)
#endif
    ...

@honggyukim
Copy link
Owner Author

$ cat gcc/config/arm/linux-elf.h
    ...
/* Call the function profiler with a given profile label.  */
#undef  ARM_FUNCTION_PROFILER
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO)                          \
{                                                                       \
  fprintf (STREAM, "\tbl\tmcount%s\n",                                  \
           (TARGET_ARM && NEED_PLT_RELOC) ? "(PLT)" : "");              \
}
    ...

@honggyukim
Copy link
Owner Author

profile_function() in final.c outputs the .data section, FUNCTION_PROFILER will output the .text section.

$ cat gcc/final.c
    ...
static void
profile_function (FILE *file ATTRIBUTE_UNUSED)
{
#ifndef NO_PROFILE_COUNTERS
# define NO_PROFILE_COUNTERS    0
#endif
#ifdef ASM_OUTPUT_REG_PUSH
  rtx sval = NULL, chain = NULL;

  if (cfun->returns_struct)
    sval = targetm.calls.struct_value_rtx (TREE_TYPE (current_function_decl),
                                           true);
  if (cfun->static_chain_decl)
    chain = targetm.calls.static_chain (current_function_decl, true);
#endif /* ASM_OUTPUT_REG_PUSH */

  if (! NO_PROFILE_COUNTERS)
    {
      int align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE);
      switch_to_section (data_section);
      ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
      targetm.asm_out.internal_label (file, "LP", current_function_funcdef_no);
      assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, align, 1);
    }

  switch_to_section (current_function_section ());

#ifdef ASM_OUTPUT_REG_PUSH
  if (sval && REG_P (sval))
    ASM_OUTPUT_REG_PUSH (file, REGNO (sval));
  if (chain && REG_P (chain))
    ASM_OUTPUT_REG_PUSH (file, REGNO (chain));
#endif

  FUNCTION_PROFILER (file, current_function_funcdef_no);

#ifdef ASM_OUTPUT_REG_PUSH
  if (chain && REG_P (chain))
    ASM_OUTPUT_REG_POP (file, REGNO (chain));
  if (sval && REG_P (sval))
    ASM_OUTPUT_REG_POP (file, REGNO (sval));
#endif
}
    ...

@honggyukim
Copy link
Owner Author

-fprolog-pad=N,M

honggyukim pushed a commit that referenced this issue Nov 10, 2019
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]>
honggyukim added a commit that referenced this issue Nov 27, 2019
This patch is to fix the following memory leak.

  $ uftrace record t-abc
  $ uftrace report -t 3us --no-pager
    Total time   Self time       Calls  Function
    ==========  ==========  ==========  ====================
      4.163 us    1.000 us           1  main
      3.163 us    3.163 us           1  a

  =================================================================
  ==78057==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 6 byte(s) in 1 object(s) allocated from:
      #0 0x7f6c4cf5734f in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x6234f)
      #1 0x498e46 in process_perf_event /home/honggyu/work/uftrace/utils/perf.c:576
      #2 0x487755 in __read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2060
      #3 0x488445 in read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2210
      #4 0x440503 in build_function_tree /home/honggyu/work/uftrace/cmds/report.c:117
      #5 0x440ba3 in report_functions /home/honggyu/work/uftrace/cmds/report.c:227
      #6 0x4442ca in command_report /home/honggyu/work/uftrace/cmds/report.c:692
      #7 0x40b843 in main /home/honggyu/work/uftrace/uftrace.c:1190
      #8 0x7f6c4b8dd82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

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

Fixed: namhyung#1023

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 27, 2019
This patch is to fix the following heap buffer overflow problem.

  $ uftrace record --force gcc hello.c
  $ uftrace replay --no-pager
      ...
  =================================================================
  ==79233==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62e00003c3e8 at
                                    pc 0x00000047e08e bp 0x7ffec89b7cd0 sp 0x7ffec89b7cc0
  READ of size 8 at 0x62e00003c3e8 thread T0
      #0 0x47e08d in fstack_check_skip /home/honggyu/uftrace/utils/fstack.c:683
      #1 0x47e9af in fstack_skip /home/honggyu/uftrace/utils/fstack.c:780
      #2 0x43e24e in print_graph_rstack /home/honggyu/uftrace/cmds/replay.c:987
      #3 0x43f49b in command_replay /home/honggyu/uftrace/cmds/replay.c:1172
      #4 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #5 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #6 0x405bf8 in _start (/home/honggyu/usr/bin/uftrace+0x405bf8)

  0x62e00003c3e8 is located 24 bytes to the left of 40960-byte region [0x62e00003c400,0x62e000046400)
  allocated by thread T0 here:
      #0 0x7f8eccd2e7fa in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x987fa)
      #1 0x479eca in setup_task_handle /home/honggyu/uftrace/utils/fstack.c:61
      #2 0x47b0e2 in fstack_setup_task /home/honggyu/uftrace/utils/fstack.c:211
      #3 0x47c23b in fstack_setup_filters /home/honggyu/uftrace/utils/fstack.c:443
      #4 0x43f266 in command_replay /home/honggyu/uftrace/cmds/replay.c:1144
      #5 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #6 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

  SUMMARY: AddressSanitizer: heap-buffer-overflow /home/honggyu/uftrace/utils/fstack.c:683 fstack_check_skip

Fixed: namhyung#803

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 28, 2019
This patch is to fix the following memory leak.

  $ uftrace record t-abc
  $ uftrace report -t 3us --no-pager
    Total time   Self time       Calls  Function
    ==========  ==========  ==========  ====================
      4.163 us    1.000 us           1  main
      3.163 us    3.163 us           1  a

  =================================================================
  ==78057==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 6 byte(s) in 1 object(s) allocated from:
      #0 0x7f6c4cf5734f in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x6234f)
      #1 0x498e46 in process_perf_event /home/honggyu/work/uftrace/utils/perf.c:576
      #2 0x487755 in __read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2060
      #3 0x488445 in read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2210
      #4 0x440503 in build_function_tree /home/honggyu/work/uftrace/cmds/report.c:117
      #5 0x440ba3 in report_functions /home/honggyu/work/uftrace/cmds/report.c:227
      #6 0x4442ca in command_report /home/honggyu/work/uftrace/cmds/report.c:692
      #7 0x40b843 in main /home/honggyu/work/uftrace/uftrace.c:1190
      #8 0x7f6c4b8dd82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

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

Fixed: namhyung#1023

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 28, 2019
This patch is to fix the following heap buffer overflow problem.

  $ uftrace record --force gcc hello.c
  $ uftrace replay --no-pager
      ...
  =================================================================
  ==79233==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62e00003c3e8 at
                                    pc 0x00000047e08e bp 0x7ffec89b7cd0 sp 0x7ffec89b7cc0
  READ of size 8 at 0x62e00003c3e8 thread T0
      #0 0x47e08d in fstack_check_skip /home/honggyu/uftrace/utils/fstack.c:683
      #1 0x47e9af in fstack_skip /home/honggyu/uftrace/utils/fstack.c:780
      #2 0x43e24e in print_graph_rstack /home/honggyu/uftrace/cmds/replay.c:987
      #3 0x43f49b in command_replay /home/honggyu/uftrace/cmds/replay.c:1172
      #4 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #5 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #6 0x405bf8 in _start (/home/honggyu/usr/bin/uftrace+0x405bf8)

  0x62e00003c3e8 is located 24 bytes to the left of 40960-byte region [0x62e00003c400,0x62e000046400)
  allocated by thread T0 here:
      #0 0x7f8eccd2e7fa in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x987fa)
      #1 0x479eca in setup_task_handle /home/honggyu/uftrace/utils/fstack.c:61
      #2 0x47b0e2 in fstack_setup_task /home/honggyu/uftrace/utils/fstack.c:211
      #3 0x47c23b in fstack_setup_filters /home/honggyu/uftrace/utils/fstack.c:443
      #4 0x43f266 in command_replay /home/honggyu/uftrace/cmds/replay.c:1144
      #5 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #6 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

  SUMMARY: AddressSanitizer: heap-buffer-overflow /home/honggyu/uftrace/utils/fstack.c:683 fstack_check_skip

Fixed: namhyung#803

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 28, 2019
This patch is to fix the following memory leak.

  $ uftrace record t-abc
  $ uftrace report -t 3us --no-pager
    Total time   Self time       Calls  Function
    ==========  ==========  ==========  ====================
      4.163 us    1.000 us           1  main
      3.163 us    3.163 us           1  a

  =================================================================
  ==78057==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 6 byte(s) in 1 object(s) allocated from:
      #0 0x7f6c4cf5734f in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x6234f)
      #1 0x498e46 in process_perf_event /home/honggyu/work/uftrace/utils/perf.c:576
      #2 0x487755 in __read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2060
      #3 0x488445 in read_rstack /home/honggyu/work/uftrace/utils/fstack.c:2210
      #4 0x440503 in build_function_tree /home/honggyu/work/uftrace/cmds/report.c:117
      #5 0x440ba3 in report_functions /home/honggyu/work/uftrace/cmds/report.c:227
      #6 0x4442ca in command_report /home/honggyu/work/uftrace/cmds/report.c:692
      #7 0x40b843 in main /home/honggyu/work/uftrace/uftrace.c:1190
      #8 0x7f6c4b8dd82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

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

Fixed: namhyung#1023

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 28, 2019
This patch is to fix the following heap buffer overflow problem.

  $ uftrace record --force gcc hello.c
  $ uftrace replay --no-pager
      ...
  =================================================================
  ==79233==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62e00003c3e8 at
                                    pc 0x00000047e08e bp 0x7ffec89b7cd0 sp 0x7ffec89b7cc0
  READ of size 8 at 0x62e00003c3e8 thread T0
      #0 0x47e08d in fstack_check_skip /home/honggyu/uftrace/utils/fstack.c:683
      #1 0x47e9af in fstack_skip /home/honggyu/uftrace/utils/fstack.c:780
      #2 0x43e24e in print_graph_rstack /home/honggyu/uftrace/cmds/replay.c:987
      #3 0x43f49b in command_replay /home/honggyu/uftrace/cmds/replay.c:1172
      #4 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #5 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #6 0x405bf8 in _start (/home/honggyu/usr/bin/uftrace+0x405bf8)

  0x62e00003c3e8 is located 24 bytes to the left of 40960-byte region [0x62e00003c400,0x62e000046400)
  allocated by thread T0 here:
      #0 0x7f8eccd2e7fa in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x987fa)
      #1 0x479eca in setup_task_handle /home/honggyu/uftrace/utils/fstack.c:61
      #2 0x47b0e2 in fstack_setup_task /home/honggyu/uftrace/utils/fstack.c:211
      #3 0x47c23b in fstack_setup_filters /home/honggyu/uftrace/utils/fstack.c:443
      #4 0x43f266 in command_replay /home/honggyu/uftrace/cmds/replay.c:1144
      #5 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #6 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

  SUMMARY: AddressSanitizer: heap-buffer-overflow /home/honggyu/uftrace/utils/fstack.c:683 fstack_check_skip

Fixed: namhyung#803

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Dec 1, 2019
This patch is to fix the following heap buffer overflow problem.

  $ uftrace record --force gcc hello.c
  $ uftrace replay --no-pager
      ...
  =================================================================
  ==79233==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62e00003c3e8 at
                                    pc 0x00000047e08e bp 0x7ffec89b7cd0 sp 0x7ffec89b7cc0
  READ of size 8 at 0x62e00003c3e8 thread T0
      #0 0x47e08d in fstack_check_skip /home/honggyu/uftrace/utils/fstack.c:683
      #1 0x47e9af in fstack_skip /home/honggyu/uftrace/utils/fstack.c:780
      #2 0x43e24e in print_graph_rstack /home/honggyu/uftrace/cmds/replay.c:987
      #3 0x43f49b in command_replay /home/honggyu/uftrace/cmds/replay.c:1172
      #4 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #5 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #6 0x405bf8 in _start (/home/honggyu/usr/bin/uftrace+0x405bf8)

  0x62e00003c3e8 is located 24 bytes to the left of 40960-byte region [0x62e00003c400,0x62e000046400)
  allocated by thread T0 here:
      #0 0x7f8eccd2e7fa in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x987fa)
      #1 0x479eca in setup_task_handle /home/honggyu/uftrace/utils/fstack.c:61
      #2 0x47b0e2 in fstack_setup_task /home/honggyu/uftrace/utils/fstack.c:211
      #3 0x47c23b in fstack_setup_filters /home/honggyu/uftrace/utils/fstack.c:443
      #4 0x43f266 in command_replay /home/honggyu/uftrace/cmds/replay.c:1144
      #5 0x40b7f1 in main /home/honggyu/uftrace/uftrace.c:1184
      #6 0x7f8ecb67e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

  SUMMARY: AddressSanitizer: heap-buffer-overflow /home/honggyu/uftrace/utils/fstack.c:683 fstack_check_skip

Fixed: namhyung#803

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jun 6, 2020
Sometimes it's useful to print backtrace or stacktrace by explicitly
write a request inside source code.

Example output:
  Stack trace:
    #0 uftrace() [0x410093]
    #1 uftrace() [0x410602]
    #2 uftrace() [0x4108e7]
    #3 uftrace(command_report+0x374) [0x411995]
    #4 uftrace(main+0x4f7) [0x40c7c5]
    #5 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f5e346d2830]
    #6 uftrace(_start+0x29) [0x40a0d9]

Some functions do not show their name, but it's because they are static functions.

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jun 6, 2020
CHECK is same as assert, but dumps stacktrace before stopped.

However, DCHECK is only compiled when DEBUG=1 is on in debug mode build.
Otherwise, it's simply ignored and doesn't make any overhead.

It would be better if we add more assertion like statements with CHECK
and DCHECK.

Here is the example output.

  /home/honggyu/work/uftrace/cmds/report.c:98: add_remaining_fstack: CHECK `root' failed.
  Stack trace:
    #0 uftrace() [0x40ffed]
    #1 uftrace() [0x410542]
    #2 uftrace() [0x410827]
    #3 uftrace(command_report+0x374) [0x4118d5]
    #4 uftrace(main+0x4f7) [0x40c7c5]
    #5 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f1552007830]
    #6 uftrace(_start+0x29) [0x40a0d9]

  Please report this uftrace internal bug to https://github.com/namhyung/uftrace/issues
  Aborted (core dumped)

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Sep 30, 2020
The kernel tracing generates kernel-cpuXX.dat in 600 mode so it cannot
be read in other environments unlike other files that gives read
permission to other accounts.

  $ ls -l uftrace.data/
      ...
  -rw-r--r-- 1 root root   15910 Sep 29 09:15 info
  -rw-r--r-- 1 root root 4851625 Sep 29 09:15 kallsyms
  -rw------- 1 root root       0 Sep 29 09:15 kernel-cpu0.dat
  -rw------- 1 root root       0 Sep 29 09:15 kernel-cpu1.dat
      ...

It makes the recorded data not portable so the other user can see the
crash as follows.

  $ uftrace replay --no-pager
  Segmentation fault (core dumped)

The crash backtrace is as follows.

  $ uftrace replay --no-pager
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==37436==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008
                  (pc 0x0000004afdad bp 0x7ffd328c53d0 sp 0x7ffd328c53c0 T0)
  ==37436==The signal is caused by a READ memory access.
  ==37436==Hint: address points to the zero page.
      #0 0x4afdac in list_del /home/honggyu/work/uftrace/utils/list.h:111
      #1 0x4b7428 in reset_rstack_list /home/honggyu/work/uftrace/utils/fstack.c:1079
      #2 0x46d4a1 in finish_kernel_data /home/honggyu/work/uftrace/utils/kernel.c:1322
      #3 0x46d060 in setup_kernel_data /home/honggyu/work/uftrace/utils/kernel.c:1284
      #4 0x483c87 in open_data_file /home/honggyu/work/uftrace/utils/data-file.c:605
      #5 0x4308e3 in command_replay /home/honggyu/work/uftrace/cmds/replay.c:1175
      #6 0x40c707 in main /home/honggyu/work/uftrace/uftrace.c:1345
      #7 0x7fef4dfe282f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #8 0x405e08 in _start (/home/honggyu/usr/bin/uftrace+0x405e08)
  AddressSanitizer can not provide additional info.
  SUMMARY: AddressSanitizer: SEGV /home/honggyu/work/uftrace/utils/list.h:111 in list_del
  ==37436==ABORTING

This patch changes the permission of kernel-cpuXX.dat file from 600 to
644 to avoid this kind of segfault.

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Oct 2, 2020
The kernel tracing generates kernel-cpuXX.dat in 600 mode so it cannot
be read in other environments unlike other files that gives read
permission to other accounts.

  $ ls -l uftrace.data/
      ...
  -rw-r--r-- 1 root root   15910 Sep 29 09:15 info
  -rw-r--r-- 1 root root 4851625 Sep 29 09:15 kallsyms
  -rw------- 1 root root       0 Sep 29 09:15 kernel-cpu0.dat
  -rw------- 1 root root       0 Sep 29 09:15 kernel-cpu1.dat
      ...

It makes the recorded data not portable so the other user can see the
crash as follows.

  $ uftrace replay --no-pager
  Segmentation fault (core dumped)

The crash backtrace is as follows.

  $ uftrace replay --no-pager
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==37436==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008
                  (pc 0x0000004afdad bp 0x7ffd328c53d0 sp 0x7ffd328c53c0 T0)
  ==37436==The signal is caused by a READ memory access.
  ==37436==Hint: address points to the zero page.
      #0 0x4afdac in list_del /home/honggyu/work/uftrace/utils/list.h:111
      #1 0x4b7428 in reset_rstack_list /home/honggyu/work/uftrace/utils/fstack.c:1079
      #2 0x46d4a1 in finish_kernel_data /home/honggyu/work/uftrace/utils/kernel.c:1322
      #3 0x46d060 in setup_kernel_data /home/honggyu/work/uftrace/utils/kernel.c:1284
      #4 0x483c87 in open_data_file /home/honggyu/work/uftrace/utils/data-file.c:605
      #5 0x4308e3 in command_replay /home/honggyu/work/uftrace/cmds/replay.c:1175
      #6 0x40c707 in main /home/honggyu/work/uftrace/uftrace.c:1345
      #7 0x7fef4dfe282f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #8 0x405e08 in _start (/home/honggyu/usr/bin/uftrace+0x405e08)
  AddressSanitizer can not provide additional info.
  SUMMARY: AddressSanitizer: SEGV /home/honggyu/work/uftrace/utils/list.h:111 in list_del
  ==37436==ABORTING

This patch changes the permission of kernel-cpuXX.dat file from 600 to
644 to avoid this kind of segfault.

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Oct 4, 2020
This patch fixes the following heap buffer overflow.

  $ gcc -pg -g -o t-arg tests/s-arg.c

  $ uftrace record -a t-arg

  $ uftrace script -S scripts/dump.py --no-pager
  uftrace_begin(ctx)
    record  : False
    version : v0.9.4-129-g4be7 ( dwarf python luajit tui perf sched dynamic )
    cmds    :

  17910610.546322424  34457: [entry] __monstartup(4005b0) depth: 0
  17910610.546323121  34457: [exit ] __monstartup(4005b0) depth: 0
  17910610.546324914  34457: [entry] __cxa_atexit(4005d0) depth: 0
  17910610.546325298  34457: [exit ] __cxa_atexit(4005d0) depth: 0
  17910610.546325981  34457: [entry] main(400a6f) depth: 0
    args[0] <class 'int'>: 1
    args[1] <class 'int'>: 140727876517768
  17910610.546326972  34457: [entry] foo(40076c) depth: 1
    args[0] <class 'int'>: 3
  =================================================================
  ==34847==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000a8892 at pc 0x7ffb47655260 bp 0x7ffe54f558d0 sp 0x7ffe54f55078
  READ of size 4 at 0x6020000a8892 thread T0
      #0 0x7ffb4765525f  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xd925f)
      #1 0x489f7e in setup_argument_context /home/honggyu/uftrace/utils/script-python.c:498
      #2 0x48a7a7 in python_uftrace_entry /home/honggyu/uftrace/utils/script-python.c:592
      #3 0x41395a in run_script_for_rstack /home/honggyu/uftrace/cmds/script.c:78
      #4 0x4146de in command_script /home/honggyu/uftrace/cmds/script.c:192
      #5 0x40c820 in main /home/honggyu/uftrace/uftrace.c:1366
      #6 0x7ffb45f0d82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #7 0x405e08 in _start (/home/honkim01/usr/bin/uftrace+0x405e08)

  0x6020000a8892 is located 0 bytes to the right of 2-byte region [0x6020000a8890,0x6020000a8892)
  allocated by thread T0 here:
      #0 0x7ffb47688078 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10c078)
      #1 0x489e85 in setup_argument_context /home/honggyu/uftrace/utils/script-python.c:491
      #2 0x48a7a7 in python_uftrace_entry /home/honggyu/uftrace/utils/script-python.c:592
      #3 0x41395a in run_script_for_rstack /home/honggyu/uftrace/cmds/script.c:78
      #4 0x4146de in command_script /home/honggyu/uftrace/cmds/script.c:192
      #5 0x40c820 in main /home/honggyu/uftrace/uftrace.c:1366
      #6 0x7ffb45f0d82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Nov 7, 2020
This patch fixes the following heap buffer overflow.

  $ gcc -pg -g -o t-arg tests/s-arg.c

  $ uftrace record -a t-arg

  $ uftrace script -S scripts/dump.py --no-pager
  uftrace_begin(ctx)
    record  : False
    version : v0.9.4-129-g4be7 ( dwarf python luajit tui perf sched dynamic )
    cmds    :

  17910610.546322424  34457: [entry] __monstartup(4005b0) depth: 0
  17910610.546323121  34457: [exit ] __monstartup(4005b0) depth: 0
  17910610.546324914  34457: [entry] __cxa_atexit(4005d0) depth: 0
  17910610.546325298  34457: [exit ] __cxa_atexit(4005d0) depth: 0
  17910610.546325981  34457: [entry] main(400a6f) depth: 0
    args[0] <class 'int'>: 1
    args[1] <class 'int'>: 140727876517768
  17910610.546326972  34457: [entry] foo(40076c) depth: 1
    args[0] <class 'int'>: 3
  =================================================================
  ==34847==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000a8892 at pc 0x7ffb47655260 bp 0x7ffe54f558d0 sp 0x7ffe54f55078
  READ of size 4 at 0x6020000a8892 thread T0
      #0 0x7ffb4765525f  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xd925f)
      #1 0x489f7e in setup_argument_context /home/honggyu/uftrace/utils/script-python.c:498
      #2 0x48a7a7 in python_uftrace_entry /home/honggyu/uftrace/utils/script-python.c:592
      #3 0x41395a in run_script_for_rstack /home/honggyu/uftrace/cmds/script.c:78
      #4 0x4146de in command_script /home/honggyu/uftrace/cmds/script.c:192
      #5 0x40c820 in main /home/honggyu/uftrace/uftrace.c:1366
      #6 0x7ffb45f0d82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
      #7 0x405e08 in _start (/home/honkim01/usr/bin/uftrace+0x405e08)

  0x6020000a8892 is located 0 bytes to the right of 2-byte region [0x6020000a8890,0x6020000a8892)
  allocated by thread T0 here:
      #0 0x7ffb47688078 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10c078)
      #1 0x489e85 in setup_argument_context /home/honggyu/uftrace/utils/script-python.c:491
      #2 0x48a7a7 in python_uftrace_entry /home/honggyu/uftrace/utils/script-python.c:592
      #3 0x41395a in run_script_for_rstack /home/honggyu/uftrace/cmds/script.c:78
      #4 0x4146de in command_script /home/honggyu/uftrace/cmds/script.c:192
      #5 0x40c820 in main /home/honggyu/uftrace/uftrace.c:1366
      #6 0x7ffb45f0d82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
Sometimes it's useful to print backtrace or stacktrace by explicitly
write a request inside source code.

This patch implements stacktrace() function for this.  It's implemented
in two different versions.  In debug mode, it uses an external libunwind
library and it's output looks as follows.

  Stack trace:
    #1  0x00000045390a fstack_update_stack_count + 0x2c
    #2  0x000000454081 __fstack_consume + 0x48f
    #3  0x000000454b62 __read_rstack + 0x74e
    #4  0x000000454bbb read_rstack + 0x28
    #5  0x000000417386 command_replay + 0x28e
    #6  0x000000407bf9 main + 0x4c3
    #7  0x7f6d119f9840 __libc_start_main + 0xf0
    #8  0x0000004054e9 _start + 0x29
    #9  0x000000000000  + 0x29

In release mode, it's better not to rely on an external library, so it
just uses builtin backtrace() function, but it can't print static
functions.  The example output looks as follows.

  Stack trace:
    #1  uftrace() [0x442277]
    #2  uftrace() [0x443ced]
    #3  uftrace(command_replay+0xe8) [0x415f28]
    #4  uftrace(main+0x544) [0x40ae14]
    #5  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f52982e0840]
    #6  uftrace(_start+0x29) [0x40af49]

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
ASSERT is same as assert, but dumps stacktrace before stopped.

However, DASSERT is only compiled when DEBUG=1 is on in debug mode build.
Otherwise, it's simply ignored and doesn't make any overhead.

It would be better if we add more assertion like statements with ASSERT
and DASSERT.

When one of the assertion is failed, it prints the stack trace and
raises SIGTRAP signal so that it can be handled by a debugger, otherwise
it will just stop execution anyway.

Here is the example output.

  /data_sdb/honggyu/work/uftrace/git/uftrace/utils/fstack.c:2025: fstack_update_stack_count: ASSERT `!task' failed.
  Stack trace:
    #1  0x0000004559f2 fstack_update_stack_count + 0x66
    #2  0x000000456187 __fstack_consume + 0x48f
    #3  0x000000456c68 __read_rstack + 0x74e
    #4  0x000000456cc1 read_rstack + 0x28
    #5  0x000000417386 command_replay + 0x28e
    #6  0x000000407bf9 main + 0x4c3
    #7  0x7fd2a7bee840 __libc_start_main + 0xf0
    #8  0x0000004054e9 _start + 0x29
    #9  0x000000000000  + 0x29

  Please report this bug to https://github.com/namhyung/uftrace/issues.

  Trace/breakpoint trap

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
Sometimes it's useful to print backtrace or stacktrace by explicitly
write a request inside source code.

This patch implements stacktrace() function for this.  It's implemented
in two different versions.  In debug mode, it uses an external libunwind
library and it's output looks as follows.

  Stack trace:
    #1  0x000000449ef9 parse_argspec + 0x5d6
    #2  0x00000044b76c parse_argument_spec + 0x70
    #3  0x00000044bf58 setup_trigger_action + 0x146
    #4  0x0000004329e5 find_dwarf_argspec + 0x153
    #5  0x000000432b18 find_auto_argspec + 0x4c
    #6  0x00000044b102 add_filter + 0x87
    #7  0x00000044c1bf add_trigger_entry + 0x15c
    #8  0x00000044c61f setup_trigger + 0x413
    #9  0x00000044c85b uftrace_setup_argument + 0x59
    #10 0x00000044e053 build_arg_spec + 0x4f
    #11 0x00000042a6fe walk_sessions + 0x4a
    #12 0x00000044e12d setup_fstack_args + 0x7d
    #13 0x00000043a353 open_data_file + 0x3ff
    #14 0x0000004171a5 command_replay + 0x7a
    #15 0x000000407ba9 main + 0x4c3
    #16 0x7f4e1df33840 __libc_start_main + 0xf0
    #17 0x000000405499 _start + 0x29

In release mode, it's better not to rely on an external library, so it
just uses builtin backtrace() function, but it can't print static
functions.  The example output looks as follows.

  Stack trace:
    #1  uftrace(parse_argspec+0x4d1) [0x43dd01]
    #2  uftrace() [0x43e44c]
    #3  uftrace(setup_trigger_action+0xb0) [0x43f4e0]
    #4  uftrace() [0x42a933]
    #5  uftrace(find_auto_argspec+0x29) [0x42aff9]
    #6  uftrace() [0x43f2f7]
    #7  uftrace() [0x43fa20]
    #8  uftrace() [0x440140]
    #9  uftrace(walk_sessions+0x39) [0x4248a9]
    #10 uftrace(setup_fstack_args+0xa6) [0x440bb6]
    #11 uftrace(open_data_file+0x16f) [0x43012f]
    #12 uftrace(command_replay+0x59) [0x415ee9]
    #13 uftrace(main+0x544) [0x40adc4]
    #14 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f8e3d944840]
    #15 uftrace(_start+0x29) [0x40aef9]

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
ASSERT is same as assert, but dumps stacktrace before stopped.

However, DASSERT is only compiled when DEBUG=1 is on in debug mode build.
Otherwise, it's simply ignored and doesn't make any overhead.

It would be better if we add more assertion like statements with ASSERT
and DASSERT.

When one of the assertion is failed, it prints the stack trace and
raises SIGTRAP signal so that it can be handled by a debugger, otherwise
it will just stop execution anyway.

Here is the example output.

  /data_sdb/honggyu/work/uftrace/git/uftrace/utils/fstack.c:2025: fstack_update_stack_count: ASSERT `!task' failed.
  Stack trace:
    #1  0x0000004559f2 fstack_update_stack_count + 0x66
    #2  0x000000456187 __fstack_consume + 0x48f
    #3  0x000000456c68 __read_rstack + 0x74e
    #4  0x000000456cc1 read_rstack + 0x28
    #5  0x000000417386 command_replay + 0x28e
    #6  0x000000407bf9 main + 0x4c3
    #7  0x7fd2a7bee840 __libc_start_main + 0xf0
    #8  0x0000004054e9 _start + 0x29
    #9  0x000000000000  + 0x29

  Please report this bug to https://github.com/namhyung/uftrace/issues.

  Trace/breakpoint trap

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
Sometimes it's useful to print backtrace or stacktrace by explicitly
write a request inside source code.

This patch implements stacktrace() function for this.  It's implemented
in two different versions.  In debug mode, it uses an external libunwind
library and it's output looks as follows.

  Stack trace:
    #1  0x000000449ef9 parse_argspec + 0x5d6
    #2  0x00000044b76c parse_argument_spec + 0x70
    #3  0x00000044bf58 setup_trigger_action + 0x146
    #4  0x0000004329e5 find_dwarf_argspec + 0x153
    #5  0x000000432b18 find_auto_argspec + 0x4c
    #6  0x00000044b102 add_filter + 0x87
    #7  0x00000044c1bf add_trigger_entry + 0x15c
    #8  0x00000044c61f setup_trigger + 0x413
    #9  0x00000044c85b uftrace_setup_argument + 0x59
    #10 0x00000044e053 build_arg_spec + 0x4f
    #11 0x00000042a6fe walk_sessions + 0x4a
    #12 0x00000044e12d setup_fstack_args + 0x7d
    #13 0x00000043a353 open_data_file + 0x3ff
    #14 0x0000004171a5 command_replay + 0x7a
    #15 0x000000407ba9 main + 0x4c3
    #16 0x7f4e1df33840 __libc_start_main + 0xf0
    #17 0x000000405499 _start + 0x29

In release mode, it's better not to rely on an external library, so it
just uses builtin backtrace() function, but it can't print static
functions.  The example output looks as follows.

  Stack trace:
    #1  uftrace(parse_argspec+0x4d1) [0x43dd01]
    #2  uftrace() [0x43e44c]
    #3  uftrace(setup_trigger_action+0xb0) [0x43f4e0]
    #4  uftrace() [0x42a933]
    #5  uftrace(find_auto_argspec+0x29) [0x42aff9]
    #6  uftrace() [0x43f2f7]
    #7  uftrace() [0x43fa20]
    #8  uftrace() [0x440140]
    #9  uftrace(walk_sessions+0x39) [0x4248a9]
    #10 uftrace(setup_fstack_args+0xa6) [0x440bb6]
    #11 uftrace(open_data_file+0x16f) [0x43012f]
    #12 uftrace(command_replay+0x59) [0x415ee9]
    #13 uftrace(main+0x544) [0x40adc4]
    #14 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f8e3d944840]
    #15 uftrace(_start+0x29) [0x40aef9]

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jul 11, 2021
ASSERT is same as assert, but dumps stacktrace before stopped.

However, DASSERT is only compiled when DEBUG=1 is on in debug mode build.
Otherwise, it's simply ignored and doesn't make any overhead.

It would be better if we add more assertion like statements with ASSERT
and DASSERT.

When one of the assertion is failed, it prints the stack trace and
raises SIGTRAP signal so that it can be handled by a debugger, otherwise
it will just stop execution anyway.

Here is the example output.

  /data_sdb/honggyu/work/uftrace/git/uftrace/utils/fstack.c:2025: fstack_update_stack_count: ASSERT `!task' failed.
  Stack trace:
    #1  0x0000004559f2 fstack_update_stack_count + 0x66
    #2  0x000000456187 __fstack_consume + 0x48f
    #3  0x000000456c68 __read_rstack + 0x74e
    #4  0x000000456cc1 read_rstack + 0x28
    #5  0x000000417386 command_replay + 0x28e
    #6  0x000000407bf9 main + 0x4c3
    #7  0x7fd2a7bee840 __libc_start_main + 0xf0
    #8  0x0000004054e9 _start + 0x29
    #9  0x000000000000  + 0x29

  Please report this bug to https://github.com/namhyung/uftrace/issues.

  Trace/breakpoint trap

Signed-off-by: Honggyu Kim <[email protected]>
honggyukim added a commit that referenced this issue Jan 2, 2022
This patch enables clang build along with existing gcc build.

However, clang build with address sanitizer creates zero padding in
"uftrace.unit_test" section unlike gcc so we explicitly add no_sanitize
attribute to unittest for clang compiler.

Otherwise, clang with asan build hits the following error.

  $ make ASAN=1 unittest
      ...
  unittest.c:164:14: runtime error: null pointer passed as argument 1, which is declared to never be null
  /usr/include/string.h:141:33: note: nonnull attribute specified here
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior unittest.c:164:14 in
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==29255==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000431b90 bp 0x7ffec6c3ed80 sp 0x7ffec6c3e520 T0)
  ==29255==The signal is caused by a READ memory access.
  ==29255==Hint: address points to the zero page.
      #0 0x431b90 in strcmp (/home/honggyu/uftrace/tests/unittest+0x431b90)
      #1 0x4cab6f in sort_tests /home/honggyu/uftrace/tests/unittest.c:164:7
      #2 0x47755b in qsort (/home/honggyu/uftrace/tests/unittest+0x47755b)
      #3 0x4c892e in setup_unit_test /home/honggyu/uftrace/tests/unittest.c:227:2
      #4 0x4c71db in main /home/honggyu/uftrace/tests/unittest.c:279:6
      #5 0x7f487ed1983f in __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:291
      #6 0x41e568 in _start (/home/honggyu/uftrace/tests/unittest+0x41e568)

  AddressSanitizer can not provide additional info.
  SUMMARY: AddressSanitizer: SEGV (/home/honggyu/uftrace/tests/unittest+0x431b90) in strcmp
  ==29255==ABORTING

Signed-off-by: Honggyu Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant