Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1383020
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] perf script: fix segfault when printing callchains using builtin-script |
| Date | 2016-04-20 05:10 +0200 |
| Message-ID | <rpQGB-12v-9@gated-at.bofh.it> (permalink) |
| References | <rpQdz-yF-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Em Tue, Apr 19, 2016 at 07:32:11PM -0700, Chris Phlipot escreveu:
> This fixes a bug caused by an unitialized callchain cursor. The crash
> frist appeared in:
> 6f736735e30f ("perf evsel: Require that callchains be resolved before
> calling fprintf_{sym,callchain}")
>
> The callchain cursor is a struct that contains pointers, that when
> uninitialized will cause unpredictable behavior (usually a crash)
> when trying to append to the callchain.
>
> The existing implementation has the following issues:
> 1. The callchain cursor used is not initialized, resulting in
> unpredictable behavior when used.
> 2. The cursor is declared on the stack. Even if it is properly initalized,
> the implmentation will leak memory when the function returns,
> since all the references to the callchain_nodes allocated by
> callchain_cursor_append will be lost when the cursor goes out of
> scope.
> 3. Storing the cursor on the stack is inefficient. Even if memory is
> properly freed when it goes out of scope, a performance penalty
> will be incurred due to reallocation of callchain nodes.
> callchain_cursor_append is designed to avoid these reallocations
> when an existing cursor is reused.
>
> This patch fixes the crash by replacing cursor_callchain with a reference
> to the global callchain_cursor which also resolves all 3 issues mentioned
> above.
>
> How to reproduce the crash:
> $ perf record --call-graph=dwarf stress -t 1 -c 1
> $ perf script > /dev/null
> Segfault
My bad, applying the patch, thanks!
- Arnaldo
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] perf script: fix segfault when printing callchains using builtin-script Chris Phlipot <cphlipot0@gmail.com> - 2016-04-20 04:40 +0200 Re: [PATCH] perf script: fix segfault when printing callchains using builtin-script Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-04-20 05:10 +0200 [tip:perf/core] perf script: Fix segfault when printing callchains tip-bot for Chris Phlipot <tipbot@zytor.com> - 2016-04-27 17:40 +0200
csiph-web