Commit b13b04d9 authored by Milian Wolff's avatar Milian Wolff Committed by Arnaldo Carvalho de Melo

perf script: Initialize zstd_data

Fixes segmentation fault when trying to interpret zstd-compressed data
with perf script:

```
  $ perf record -z ls
  ...
  [ perf record: Captured and wrote 0,010 MB perf.data, compressed (original 0,001 MB, ratio is 2,190) ]
  $ memcheck perf script
  ...
  ==67911== Invalid read of size 4
  ==67911==    at 0x5568188: ZSTD_decompressStream (in /usr/lib/libzstd.so.1.4.5)
  ==67911==    by 0x6E726B: zstd_decompress_stream (zstd.c:100)
  ==67911==    by 0x65729C: perf_session__process_compressed_event (session.c:72)
  ==67911==    by 0x6598E8: perf_session__process_user_event (session.c:1583)
  ==67911==    by 0x65BA59: reader__process_events (session.c:2177)
  ==67911==    by 0x65BA59: __perf_session__process_events (session.c:2234)
  ==67911==    by 0x65BA59: perf_session__process_events (session.c:2267)
  ==67911==    by 0x5A7397: __cmd_script (builtin-script.c:2447)
  ==67911==    by 0x5A7397: cmd_script (builtin-script.c:3840)
  ==67911==    by 0x5FE9D2: run_builtin (perf.c:312)
  ==67911==    by 0x711627: handle_internal_command (perf.c:364)
  ==67911==    by 0x711627: run_argv (perf.c:408)
  ==67911==    by 0x711627: main (perf.c:538)
  ==67911==  Address 0x71d8 is not stack'd, malloc'd or (recently) free'd
```
Signed-off-by: default avatarMilian Wolff <milian.wolff@kdab.com>
Acked-by: default avatarAlexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
LPU-Reference: 20200612230333.72140-1-milian.wolff@kdab.com
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 85d0f9ad
......@@ -3837,6 +3837,9 @@ int cmd_script(int argc, const char **argv)
if (err)
goto out_delete;
if (zstd_init(&(session->zstd_data), 0) < 0)
pr_warning("Decompression initialization failed. Reported data may be incomplete.\n");
err = __cmd_script(&script);
flush_scripting();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment