perf: Live mode flamegraph recording results in segmentation fault
I've reproduced this on recent versions of Debian, Ubuntu, CentOS, and Fedora, and I used to be able to downgrade perf and it would work, but an early enough version of perf is no longer available from most package repositories.
Steps I have taken to reproduce:
1. Install perf from a distro package manager. ( sudo dnf install perf)
``` $ perf --version perf version 6.13.5-200.fc41.x86_64) ```
2. Attempt a live flamegraph report:
``` $ perf script flamegraph ls /usr/libexec/perf-core/scripts/python/bin/flamegraph-report: line 3: 1644 Segmentation fault (core dumped) perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@" ```
Quoted 14 lines · David
I've reproduced this on recent versions of Debian, Ubuntu, CentOS, and Fedora, and I used to be able to downgrade perf and it would work, but an early enough version of perf is no longer available from most package repositories.
Steps I have taken to reproduce:
1. Install perf from a distro package manager. (
sudo dnf install perf)``` $ perf --version perf version 6.13.5-200.fc41.x86_64) ```
Quoted 9 lines
2. Attempt a live flamegraph report:
``` $ perf script flamegraph ls /usr/libexec/perf-core/scripts/python/bin/flamegraph-report: line 3: 1644 Segmentation fault (core dumped) perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@" ```
Hi David,
Are you able to bisect this to find the breaking commit?
Is this the full output you get? I'm not able to reproduce your exact issue. I do see a bug with the template download prompt but it produces more output than you have:
$ perf script flamegraph ls
Warning: Flame Graph template '/usr/share/d3-flame-graph/d3- flamegraph-base.html' does not exist.
[...]
s = input("Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] ").lower()
OSError: [Errno 9] Bad file descriptor
Fatal Python error: handler_call_die: problem in Python trace event handler
Python runtime state: initialized
Current thread 0x00007d1916afd400 (most recent call first):
<no Python frame>
Extension modules: apt_pkg (total: 1)
Aborted (core dumped)
But if I avoid the record/report wrapper and go straight to the script it works:
$ perf record -g ls $ perf script flamegraph.py
[...]
Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] y
dumping data to flamegraph.html
I'm wondering if the template prompt ever worked in conjunction with the wrappers? Maybe they were only tested with the template already installed, or the script was always used directly when the need for a template was added.
Thanks
James
Quoted 67 lines · James Clark
Quoted 18 lines · David
I've reproduced this on recent versions of Debian, Ubuntu, CentOS, and Fedora,
and I used to be able to downgrade perf and it would work, but an early enough
version of perf is no longer available from most package repositories.Steps I have taken to reproduce:
1. Install perf from a distro package manager. (
sudo dnf install perf)``` $ perf --version perf version 6.13.5-200.fc41.x86_64) ```2. Attempt a live flamegraph report:
Quoted 9 lines
``` $ perf script flamegraph ls /usr/libexec/perf-core/scripts/python/bin/flamegraph-report: line 3: 1644 Segmentation fault (core dumped) perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@" ```Hi David,
Are you able to bisect this to find the breaking commit?
Is this the full output you get? I'm not able to reproduce your exact issue. I do see a bug with the template download prompt but it produces more output than you have:
$ perf script flamegraph lsWarning: Flame Graph template '
/usr/share/d3-flame-graph/d3-flamegraph-base.html' does not exist.
[...]
s = input("Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] ").lower()
OSError: [Errno 9] Bad file descriptor
Fatal Python error:handler_call_die: problem in Python trace event handler
Python runtime state: initializedCurrent thread
0x00007d1916afd400(most recent call first):
<no Python frame>Extension modules:
apt_pkg(total: 1)
Aborted (core dumped)But if I avoid the record/report wrapper and go straight to the script it works:
$ perf record -g ls $ perf script flamegraph.py[...]
Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] y
Quoted 6 lines
dumping data to flamegraph.html
I'm wondering if the template prompt ever worked in conjunction with the wrappers? Maybe they were only tested with the template already installed, or the script was always used directly when the need for a template was added.
I don't know but it didn't work well for me too. Maybe it should have default 'y' for live mode.
Thanks,
Namhyung
Quoted 75 lines · Namhyung Kim
Quoted 67 lines · James Clark
Quoted 18 lines · David
I've reproduced this on recent versions of Debian, Ubuntu, CentOS, and Fedora,
and I used to be able to downgrade perf and it would work, but an early enough
version of perf is no longer available from most package repositories.Steps I have taken to reproduce:
1. Install perf from a distro package manager. (
sudo dnf install perf)``` $ perf --version perf version 6.13.5-200.fc41.x86_64) ```2. Attempt a live flamegraph report:
Quoted 9 lines
``` $ perf script flamegraph ls /usr/libexec/perf-core/scripts/python/bin/flamegraph-report: line 3: 1644 Segmentation fault (core dumped) perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py -- "$@" ```Hi David,
Are you able to bisect this to find the breaking commit?
Is this the full output you get? I'm not able to reproduce your exact issue. I do see a bug with the template download prompt but it produces more output than you have:
$ perf script flamegraph lsWarning: Flame Graph template '
/usr/share/d3-flame-graph/d3-flamegraph-base.html' does not exist.
[...]
s = input("Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] ").lower()
OSError: [Errno 9] Bad file descriptor
Fatal Python error:handler_call_die: problem in Python trace event handler
Python runtime state: initializedCurrent thread
0x00007d1916afd400(most recent call first):
<no Python frame>Extension modules:
apt_pkg(total: 1)
Aborted (core dumped)But if I avoid the record/report wrapper and go straight to the script it works:
$ perf record -g ls $ perf script flamegraph.py[...]
Do you wish to download a template from cdn.jsdelivr.net? (this warning can be suppressed with --allow-download) [yn] yQuoted 6 lines
dumping data to flamegraph.html
I'm wondering if the template prompt ever worked in conjunction with the wrappers? Maybe they were only tested with the template already installed, or the script was always used directly when the need for a template was added.
Quoted 6 lines
I don't know but it didn't work well for me too. Maybe it should have default 'y' for live mode.
Thanks,
Namhyung
Looks like this bug was discussed previously here [2].
And the issue about shipping vs downloading here along with prompting on the original change [1]. But considering the following I think it's worth bringing it up again:
* We download a fixed version (rather than latest)
* The contents are hash checked so are fixed for that reason too
* We know network requests should be avoided (so prompt for input)
* The packaging request didn't go anywhere
In light of all of the above what's the difference between downloading it vs packaging it into Perf? It has an Apache licence, but I'm pretty sure it's separate enough for that to not be an issue.
One argument was that it's a minimized blob, but only the .min.js is. The unminimized version is available too.
[1]: https://lore.kernel.org/lkml/[email protected]/T/#mf0942ae7abc78882c9b10b1c1f18a119393e3e2b
[2]: https://lore.kernel.org/all/CAP-5=fW+jpi_iLCrpA2GeEQBzNYASF52qrX7ExrSNL82uaDREQ@mail.gmail.com/