• A
    perf list: Robustify event printing routine · fb202539
    Arnaldo Carvalho de Melo 提交于
    When a43eec30 ("bpf: introduce bpf_perf_event_output() helper") added
    PERF_COUNT_SW_BPF_OUTPUT we ended up with a new entry in the event_symbols_sw
    array that wasn't initialized, thus set to NULL, fix print_symbol_events()
    to check for that case so that we don't crash if this happens again.
    
      (gdb) bt
      #0  __match_glob (ignore_space=false, pat=<optimized out>, str=<optimized out>) at util/string.c:198
      #1  strglobmatch (str=<optimized out>, pat=pat@entry=0x7fffffffe61d "stall") at util/string.c:252
      #2  0x00000000004993a5 in print_symbol_events (type=1, syms=0x872880 <event_symbols_sw+160>, max=11, name_only=false, event_glob=0x7fffffffe61d "stall")
          at util/parse-events.c:1615
      #3  print_events (event_glob=event_glob@entry=0x7fffffffe61d "stall", name_only=false) at util/parse-events.c:1675
      #4  0x000000000042c79e in cmd_list (argc=1, argv=0x7fffffffe390, prefix=<optimized out>) at builtin-list.c:68
      #5  0x00000000004788a5 in run_builtin (p=p@entry=0x871758 <commands+120>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe390) at perf.c:370
      #6  0x0000000000420ab0 in handle_internal_command (argv=0x7fffffffe390, argc=2) at perf.c:429
      #7  run_argv (argv=0x7fffffffe110, argcp=0x7fffffffe11c) at perf.c:473
      #8  main (argc=2, argv=0x7fffffffe390) at perf.c:588
      (gdb) p event_symbols_sw[PERF_COUNT_SW_BPF_OUTPUT]
      $4 = {symbol = 0x0, alias = 0x0}
      (gdb)
    
    A patch to robustify perf to not segfault when the next counter gets added in
    the kernel will follow this one.
    Reported-by: NIngo Molnar <mingo@kernel.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-57wysblcjfrseb0zg5u7ek10@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    fb202539
parse-events.c 47.9 KB