* [PATCH] perf annotate: Fix the segmentation fault bug of perf annotate
@ 2015-03-20 13:52 Yunlong Song
2015-03-20 15:48 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Yunlong Song @ 2015-03-20 13:52 UTC (permalink / raw)
To: a.p.zijlstra, paulus, mingo, acme; +Cc: linux-kernel, wangnan0
There is a segmentation fault bug in 'perf annotate' using the perf.data
created by 'perf record -g', so fix it.
Example:
$ perf record -g ls
Before this patch:
$ perf annotate
Segmentation fault
After this patch:
$ perf annotate
Percent | Source code & Disassembly of kcore for cycles
-------------------------------------------------------------
:
:
:
: Disassembly of section load0:
:
: ffffffff8103efc0 <load0>:
0.00 : ffffffff8103efc0: mov %esi,%eax
0.00 : ffffffff8103efc2: mov %edi,%ecx
0.00 : ffffffff8103efc4: wrmsr
100.00 : ffffffff8103efc6: xor %eax,%eax
0.00 : ffffffff8103efc8: retq
Percent | Source code & Disassembly of kcore for cycles
-------------------------------------------------------------
...
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
tools/perf/util/annotate.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 61bf912..0f9ebad 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -30,6 +30,9 @@ static int disasm_line__parse(char *line, char **namep, char **rawp);
static void ins__delete(struct ins_operands *ops)
{
+ if (ops == NULL)
+ return;
+
zfree(&ops->source.raw);
zfree(&ops->source.name);
zfree(&ops->target.raw);
@@ -211,7 +214,11 @@ static int lock__scnprintf(struct ins *ins, char *bf, size_t size,
static void lock__delete(struct ins_operands *ops)
{
- struct ins *ins = ops->locked.ins;
+ struct ins *ins;
+
+ if (ops == NULL)
+ return;
+ ins = ops->locked.ins;
if (ins && ins->ops->free)
ins->ops->free(ops->locked.ops);
--
1.8.5.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] perf annotate: Fix the segmentation fault bug of perf annotate
2015-03-20 13:52 [PATCH] perf annotate: Fix the segmentation fault bug of perf annotate Yunlong Song
@ 2015-03-20 15:48 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-20 15:48 UTC (permalink / raw)
To: Yunlong Song; +Cc: a.p.zijlstra, paulus, Ingo Molnar, linux-kernel, wangnan0
Em Fri, Mar 20, 2015 at 09:52:14PM +0800, Yunlong Song escreveu:
> There is a segmentation fault bug in 'perf annotate' using the perf.data
> created by 'perf record -g', so fix it.
<SNIP>
> +++ b/tools/perf/util/annotate.c
> @@ -30,6 +30,9 @@ static int disasm_line__parse(char *line, char **namep, char **rawp);
>
> static void ins__delete(struct ins_operands *ops)
> {
> + if (ops == NULL)
> + return;
> +
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/annotate.c#n31
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/tools/perf?id=3995614d9b0320e10ce202836c8477e1bcf1a2d4
I.e. already upstream, it just needs to be merged with perf/core, either
Ingo or myself will do that soon,
- Arnaldo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-20 15:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-20 13:52 [PATCH] perf annotate: Fix the segmentation fault bug of perf annotate Yunlong Song
2015-03-20 15:48 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome