Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1343266 > unrolled thread
| Started by | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| First post | 2016-02-25 16:20 +0100 |
| Last post | 2016-02-27 10:50 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 2/3] perf script: Exception handling when the print fmt is empty Taeung Song <treeze.taeung@gmail.com> - 2016-02-25 16:20 +0100
Re: [PATCH 2/3] perf script: Exception handling when the print fmt is empty Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-25 17:00 +0100
Re: [PATCH 2/3] perf script: Exception handling when the print fmt is empty Taeung Song <treeze.taeung@gmail.com> - 2016-02-25 17:40 +0100
[tip:perf/core] perf script: Exception handling when the print fmt is empty tip-bot for Taeung Song <tipbot@zytor.com> - 2016-02-27 10:50 +0100
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2016-02-25 16:20 +0100 |
| Subject | [PATCH 2/3] perf script: Exception handling when the print fmt is empty |
| Message-ID | <r65RV-5J5-31@gated-at.bofh.it> |
After collecting samples for events 'syscalls:',
perf-script with python script doesn't occasionally
work generating a segmentation fault.
The reason is that the print fmt is empty and
a value of event->print_fmt.args is NULL, so
dereferencing the null pointer results in
a segmentation fault i.e.
# perf record -e syscalls:*
# perf script -g python
# perf script -s perf-script.py
in trace_begin
syscalls__sys_enter_brk 3 79841.832099154 3777 test.sh syscall_nr=12, brk=0
... (omitted) ...
Segmentation fault (core dumped)
For example, a format of sys_enter_getuid() hasn't
print fmt as below.
# cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_getuid/format
name: sys_enter_getuid
ID: 188
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:int syscall_nr; offset:8; size:4; signed:1;
print fmt: ""
So add exception handling to avoid this problem.
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/scripting-engines/trace-event-perl.c | 3 +++
tools/perf/util/scripting-engines/trace-event-python.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 544509c..b3aabc0 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -187,6 +187,9 @@ static void define_event_symbols(struct event_format *event,
const char *ev_name,
struct print_arg *args)
{
+ if (args == NULL)
+ return;
+
switch (args->type) {
case PRINT_NULL:
break;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index d72fafc..309d90f 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -205,6 +205,9 @@ static void define_event_symbols(struct event_format *event,
const char *ev_name,
struct print_arg *args)
{
+ if (args == NULL)
+ return;
+
switch (args->type) {
case PRINT_NULL:
break;
--
2.5.0
[toc] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-25 17:00 +0100 |
| Subject | Re: [PATCH 2/3] perf script: Exception handling when the print fmt is empty |
| Message-ID | <r66uC-603-11@gated-at.bofh.it> |
| In reply to | #1343266 |
Em Fri, Feb 26, 2016 at 12:12:59AM +0900, Taeung Song escreveu:
> After collecting samples for events 'syscalls:',
> perf-script with python script doesn't occasionally
> work generating a segmentation fault.
Thanks, applied.
- Arnaldo
> The reason is that the print fmt is empty and
> a value of event->print_fmt.args is NULL, so
> dereferencing the null pointer results in
> a segmentation fault i.e.
>
> # perf record -e syscalls:*
> # perf script -g python
> # perf script -s perf-script.py
>
> in trace_begin
> syscalls__sys_enter_brk 3 79841.832099154 3777 test.sh syscall_nr=12, brk=0
>
> ... (omitted) ...
>
> Segmentation fault (core dumped)
>
> For example, a format of sys_enter_getuid() hasn't
> print fmt as below.
>
> # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_getuid/format
> name: sys_enter_getuid
> ID: 188
> format:
> field:unsigned short common_type; offset:0; size:2; signed:0;
> field:unsigned char common_flags; offset:2; size:1; signed:0;
> field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
> field:int common_pid; offset:4; size:4; signed:1;
> field:int syscall_nr; offset:8; size:4; signed:1;
>
> print fmt: ""
>
> So add exception handling to avoid this problem.
>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Wang Nan <wangnan0@huawei.com>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
> tools/perf/util/scripting-engines/trace-event-perl.c | 3 +++
> tools/perf/util/scripting-engines/trace-event-python.c | 3 +++
> 2 files changed, 6 insertions(+)
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> index 544509c..b3aabc0 100644
> --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> @@ -187,6 +187,9 @@ static void define_event_symbols(struct event_format *event,
> const char *ev_name,
> struct print_arg *args)
> {
> + if (args == NULL)
> + return;
> +
> switch (args->type) {
> case PRINT_NULL:
> break;
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index d72fafc..309d90f 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -205,6 +205,9 @@ static void define_event_symbols(struct event_format *event,
> const char *ev_name,
> struct print_arg *args)
> {
> + if (args == NULL)
> + return;
> +
> switch (args->type) {
> case PRINT_NULL:
> break;
> --
> 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2016-02-25 17:40 +0100 |
| Subject | Re: [PATCH 2/3] perf script: Exception handling when the print fmt is empty |
| Message-ID | <r677k-6vJ-13@gated-at.bofh.it> |
| In reply to | #1343284 |
Hi, Arnaldo On 02/26/2016 12:59 AM, Arnaldo Carvalho de Melo wrote: > Em Fri, Feb 26, 2016 at 12:12:59AM +0900, Taeung Song escreveu: >> After collecting samples for events 'syscalls:', >> perf-script with python script doesn't occasionally >> work generating a segmentation fault. > > Thanks, applied. > > - Arnaldo Thank you!! Taeung
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Taeung Song <tipbot@zytor.com> |
|---|---|
| Date | 2016-02-27 10:50 +0100 |
| Subject | [tip:perf/core] perf script: Exception handling when the print fmt is empty |
| Message-ID | <r6JFF-XE-25@gated-at.bofh.it> |
| In reply to | #1343266 |
Commit-ID: 8579aca3f9a8f890d6d94ccaed7cf5fd54a0c3bd
Gitweb: http://git.kernel.org/tip/8579aca3f9a8f890d6d94ccaed7cf5fd54a0c3bd
Author: Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Fri, 26 Feb 2016 00:12:59 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 25 Feb 2016 12:54:20 -0300
perf script: Exception handling when the print fmt is empty
After collecting samples for events 'syscalls:', perf-script with python
script doesn't occasionally work generating a segmentation fault.
The reason is that the print fmt is empty and a value of
event->print_fmt.args is NULL, so dereferencing the null pointer results
in a segmentation fault i.e.:
# perf record -e syscalls:*
# perf script -g python
# perf script -s perf-script.py
in trace_begin
syscalls__sys_enter_brk 3 79841.832099154 3777 test.sh syscall_nr=12, brk=0
... (omitted) ...
Segmentation fault (core dumped)
For example, a format of sys_enter_getuid() hasn't
print fmt as below.
# cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_getuid/format
name: sys_enter_getuid
ID: 188
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:int syscall_nr; offset:8; size:4; signed:1;
print fmt: ""
So add exception handling to avoid this problem.
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1456413179-12331-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/scripting-engines/trace-event-perl.c | 3 +++
tools/perf/util/scripting-engines/trace-event-python.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 544509c..b3aabc0 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -187,6 +187,9 @@ static void define_event_symbols(struct event_format *event,
const char *ev_name,
struct print_arg *args)
{
+ if (args == NULL)
+ return;
+
switch (args->type) {
case PRINT_NULL:
break;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index d72fafc..309d90f 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -205,6 +205,9 @@ static void define_event_symbols(struct event_format *event,
const char *ev_name,
struct print_arg *args)
{
+ if (args == NULL)
+ return;
+
switch (args->type) {
case PRINT_NULL:
break;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web