Bug 201477 - perf record causes segmentation fault
Summary: perf record causes segmentation fault
Status: RESOLVED OBSOLETE
Alias: None
Product: Tracing/Profiling
Classification: Unclassified
Component: Perf tool (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Arnaldo Carvalho de Melo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-19 08:08 UTC by Yongxin Liu
Modified: 2022-01-21 06:39 UTC (History)
3 users (show)

See Also:
Kernel Version: 4.19.0-rc8
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments

Description Yongxin Liu 2018-10-19 08:08:21 UTC
"perf record" causes segmentation fault.

root@intel-x86-64:/home# perf record -e cpu-clock ls         
perf: Segmentation fault
Obtained 10 stack frames.
/perf() [0x4d618f]
/lib64/libc.so.6(+0x37120) [0x7f8f82a64120]
/perf() [0x4cbec6]
/perf() [0x41b64c]
/perf() [0x41cb1a]
/perf() [0x47f7bf]
/perf() [0x47fac1]
/perf() [0x407892]
/lib64/libc.so.6(__libc_start_main+0xeb) [0x7f8f82a5108b]
/perf() [0x407cca]
Segmentation fault (core dumped)

root@intel-x86-64:/home# perf record -e task-clock ls   
perf: Segmentation fault
Obtained 10 stack frames.
/perf() [0x4d618f]
/lib64/libc.so.6(+0x37120) [0x7f2471c03120]
/perf() [0x4cbec6]
/perf() [0x41b64c]
/perf() [0x41cb1a]
/perf() [0x47f7bf]
/perf() [0x47fac1]
/perf() [0x407892]
/lib64/libc.so.6(__libc_start_main+0xeb) [0x7f2471bf008b]
/perf() [0x407cca]
Segmentation fault (core dumped)


But there is no problem when using cpu-clock and task-clock together.

root@intel-x86-64:/home# perf record -e cpu-clock,task-clock ls 
perf  perf.data  perf.data.old
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.007 MB perf.data (16 samples) ]

Suspect that it was introduced in commit 0aa802a79469a86ebe143019144cd4df8ae852e4. Without this commit, it works well.
Comment 1 Arnaldo Carvalho de Melo 2018-10-19 18:28:02 UTC
Reproduced, looking into it.
Comment 2 Adam Lee 2018-11-12 04:36:13 UTC
From commit 0aa802a79469a86ebe143019144cd4df8ae852e4, removing the following addition in util/evsel.c resolved the bug:

```
if (perf_evsel__is_clock(evsel)) {
  /*
   * The evsel->unit points to static alias->unit
   * so it's ok to use static string in here.
   */
  static const char *unit = "msec";

  evsel->unit = unit;
  evsel->scale = 1e-6;
}
```

Cheers, 
Adam
Comment 3 Ian Rogers 2022-01-21 06:39:30 UTC
This appears to have been fixed for a while - doesn't reproduce with a 5.10 or 5.16 perf command.

Note You need to log in before you can comment on or make changes to this bug.