All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf buildid-list: Initialize zstd_data
@ 2021-04-29 18:57 Milian Wolff
  2021-05-12 15:14 ` Milian Wolff
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2021-04-29 18:57 UTC (permalink / raw)
  To: acme; +Cc: alexey.budankov, linux-perf-users, linux-kernel, Milian Wolff

Fixes segmentation fault when trying to obtain buildid list (e.g. via
perf-archive) from a zstd-compressed `perf.data` file:

```
    $ 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 buildid-list
    ...
    ==57268== Invalid read of size 4
    ==57268==    at 0x5260D88: ZSTD_decompressStream (in /usr/lib/libzstd.so.1.4.9)
    ==57268==    by 0x4BB51B: zstd_decompress_stream (zstd.c:100)
    ==57268==    by 0x425C6C: perf_session__process_compressed_event (session.c:73)
    ==57268==    by 0x427450: perf_session__process_user_event (session.c:1631)
    ==57268==    by 0x42A609: reader__process_events (session.c:2207)
    ==57268==    by 0x42A609: __perf_session__process_events (session.c:2264)
    ==57268==    by 0x42A609: perf_session__process_events (session.c:2297)
    ==57268==    by 0x343A62: perf_session__list_build_ids (builtin-buildid-list.c:88)
    ==57268==    by 0x343A62: cmd_buildid_list (builtin-buildid-list.c:120)
    ==57268==    by 0x3C7732: run_builtin (perf.c:313)
    ==57268==    by 0x331157: handle_internal_command (perf.c:365)
    ==57268==    by 0x331157: run_argv (perf.c:409)
    ==57268==    by 0x331157: main (perf.c:539)
    ==57268==  Address 0x7470 is not stack'd, malloc'd or (recently) free'd
```

Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
---
 tools/perf/builtin-buildid-list.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 87f5b1a4a7fa..833405c27dae 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -80,6 +80,9 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
 	if (!perf_header__has_feat(&session->header, HEADER_BUILD_ID))
 		with_hits = true;
 
+	if (zstd_init(&(session->zstd_data), 0) < 0)
+		pr_warning("Decompression initialization failed. Reported data may be incomplete.\n");
+
 	/*
 	 * in pipe-mode, the only way to get the buildids is to parse
 	 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf buildid-list: Initialize zstd_data
  2021-04-29 18:57 [PATCH] perf buildid-list: Initialize zstd_data Milian Wolff
@ 2021-05-12 15:14 ` Milian Wolff
  2021-05-12 15:24   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Milian Wolff @ 2021-05-12 15:14 UTC (permalink / raw)
  To: acme; +Cc: alexey.budankov, linux-perf-users, linux-kernel, acme

[-- Attachment #1: Type: text/plain, Size: 2562 bytes --]

On Donnerstag, 29. April 2021 20:57:59 CEST Milian Wolff wrote:
> Fixes segmentation fault when trying to obtain buildid list (e.g. via
> perf-archive) from a zstd-compressed `perf.data` file:

Ping, can someone please review and push this upstream? It's such a trivial 
fix, I would like to see it fixed upstream.

Thanks

> ```
>     $ 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 buildid-list
>     ...
>     ==57268== Invalid read of size 4
>     ==57268==    at 0x5260D88: ZSTD_decompressStream (in
> /usr/lib/libzstd.so.1.4.9) ==57268==    by 0x4BB51B: zstd_decompress_stream
> (zstd.c:100)
>     ==57268==    by 0x425C6C: perf_session__process_compressed_event
> (session.c:73) ==57268==    by 0x427450: perf_session__process_user_event
> (session.c:1631) ==57268==    by 0x42A609: reader__process_events
> (session.c:2207) ==57268==    by 0x42A609: __perf_session__process_events
> (session.c:2264) ==57268==    by 0x42A609: perf_session__process_events
> (session.c:2297) ==57268==    by 0x343A62: perf_session__list_build_ids
> (builtin-buildid-list.c:88) ==57268==    by 0x343A62: cmd_buildid_list
> (builtin-buildid-list.c:120) ==57268==    by 0x3C7732: run_builtin
> (perf.c:313)
>     ==57268==    by 0x331157: handle_internal_command (perf.c:365)
>     ==57268==    by 0x331157: run_argv (perf.c:409)
>     ==57268==    by 0x331157: main (perf.c:539)
>     ==57268==  Address 0x7470 is not stack'd, malloc'd or (recently) free'd
> ```
> 
> Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
> ---
>  tools/perf/builtin-buildid-list.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/builtin-buildid-list.c
> b/tools/perf/builtin-buildid-list.c index 87f5b1a4a7fa..833405c27dae 100644
> --- a/tools/perf/builtin-buildid-list.c
> +++ b/tools/perf/builtin-buildid-list.c
> @@ -80,6 +80,9 @@ static int perf_session__list_build_ids(bool force, bool
> with_hits) if (!perf_header__has_feat(&session->header, HEADER_BUILD_ID))
>  		with_hits = true;
> 
> +	if (zstd_init(&(session->zstd_data), 0) < 0)
> +		pr_warning("Decompression initialization failed. Reported data 
may be
> incomplete.\n"); +
>  	/*
>  	 * in pipe-mode, the only way to get the buildids is to parse
>  	 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID


-- 
Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5272 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf buildid-list: Initialize zstd_data
  2021-05-12 15:14 ` Milian Wolff
@ 2021-05-12 15:24   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-05-12 15:24 UTC (permalink / raw)
  To: Milian Wolff; +Cc: acme, alexey.budankov, linux-perf-users, linux-kernel, acme

Em Wed, May 12, 2021 at 05:14:29PM +0200, Milian Wolff escreveu:
> On Donnerstag, 29. April 2021 20:57:59 CEST Milian Wolff wrote:
> > Fixes segmentation fault when trying to obtain buildid list (e.g. via
> > perf-archive) from a zstd-compressed `perf.data` file:
> 
> Ping, can someone please review and push this upstream? It's such a trivial 
> fix, I would like to see it fixed upstream.

Fell thru the cracks, processing it now.

- Arnaldo
 
> Thanks
> 
> > ```
> >     $ 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 buildid-list
> >     ...
> >     ==57268== Invalid read of size 4
> >     ==57268==    at 0x5260D88: ZSTD_decompressStream (in
> > /usr/lib/libzstd.so.1.4.9) ==57268==    by 0x4BB51B: zstd_decompress_stream
> > (zstd.c:100)
> >     ==57268==    by 0x425C6C: perf_session__process_compressed_event
> > (session.c:73) ==57268==    by 0x427450: perf_session__process_user_event
> > (session.c:1631) ==57268==    by 0x42A609: reader__process_events
> > (session.c:2207) ==57268==    by 0x42A609: __perf_session__process_events
> > (session.c:2264) ==57268==    by 0x42A609: perf_session__process_events
> > (session.c:2297) ==57268==    by 0x343A62: perf_session__list_build_ids
> > (builtin-buildid-list.c:88) ==57268==    by 0x343A62: cmd_buildid_list
> > (builtin-buildid-list.c:120) ==57268==    by 0x3C7732: run_builtin
> > (perf.c:313)
> >     ==57268==    by 0x331157: handle_internal_command (perf.c:365)
> >     ==57268==    by 0x331157: run_argv (perf.c:409)
> >     ==57268==    by 0x331157: main (perf.c:539)
> >     ==57268==  Address 0x7470 is not stack'd, malloc'd or (recently) free'd
> > ```
> > 
> > Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
> > ---
> >  tools/perf/builtin-buildid-list.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-buildid-list.c
> > b/tools/perf/builtin-buildid-list.c index 87f5b1a4a7fa..833405c27dae 100644
> > --- a/tools/perf/builtin-buildid-list.c
> > +++ b/tools/perf/builtin-buildid-list.c
> > @@ -80,6 +80,9 @@ static int perf_session__list_build_ids(bool force, bool
> > with_hits) if (!perf_header__has_feat(&session->header, HEADER_BUILD_ID))
> >  		with_hits = true;
> > 
> > +	if (zstd_init(&(session->zstd_data), 0) < 0)
> > +		pr_warning("Decompression initialization failed. Reported data 
> may be
> > incomplete.\n"); +
> >  	/*
> >  	 * in pipe-mode, the only way to get the buildids is to parse
> >  	 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
> 
> 
> -- 
> Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer
> KDAB (Deutschland) GmbH, a KDAB Group company
> Tel: +49-30-521325470
> KDAB - The Qt, C++ and OpenGL Experts



-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-12 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-29 18:57 [PATCH] perf buildid-list: Initialize zstd_data Milian Wolff
2021-05-12 15:14 ` Milian Wolff
2021-05-12 15:24   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.