Public bug reported:
With package linux-tools-6.5.0-45-generic, perf will reproducibly
segfault on startup:
$ SYSFS_PATH=/nonexistent perf record /bin/echo
Failed to read max cpus, using default of 4096
libperf: Miscounted nr_mmaps 0 vs 1
WARNING: No sample_id_all support, falling back to unordered processing
perf: Segmentation fault
Under gdb:
Thread 1 "perf" received signal SIGSEGV, Segmentation fault.
0x0000555555739ca3 in __perf_cpu_map__nr (cpus=0x0) at cpumap.c:283
283 cpumap.c: No such file or directory.
(gdb) bt
#0 0x0000555555739ca3 in __perf_cpu_map__nr (cpus=0x0) at cpumap.c:283
#1 0x0000555555739f37 in perf_cpu_map__max (map=0x0) at cpumap.c:371
#2 0x00005555556ac264 in cpu_map_data__alloc
(syn_data=syn_data@entry=0x7fffffff8860, header_size=header_size@entry=8) at
util/synthetic-events.c:1273
#3 0x00005555556af6a6 in cpu_map_event__new (map=<optimized out>) at
util/synthetic-events.c:1321
#4 perf_event__synthesize_cpu_map (tool=tool@entry=0x555555e62300 <record>,
map=<optimized out>, process=process@entry=0x555555596d40
<process_synthesized_event>, machine=machine@entry=0x0)
at util/synthetic-events.c:1341
#5 0x0000555555594ddf in record__synthesize (tail=tail@entry=false,
rec=0x555555e62300 <record>) at builtin-record.c:2050
#6 0x000055555559891f in __cmd_record (argc=<optimized out>, argv=<optimized
out>, rec=0x555555e62300 <record>) at builtin-record.c:2512
#7 0x000055555559b95f in cmd_record (argc=1, argv=0x7fffffffe450) at
builtin-record.c:4260
#8 0x00005555556073f1 in run_builtin (p=p@entry=0x555555e64868 <commands+264>,
argc=argc@entry=2, argv=argv@entry=0x7fffffffe450) at perf.c:323
#9 0x000055555558580e in handle_internal_command (argv=0x7fffffffe450, argc=2)
at perf.c:377
#10 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:421
#11 main (argc=2, argv=0x7fffffffe450) at perf.c:537
The SYSFS_PATH environment variable is for your convenient reproduction.
My actual problem is that I'm trying to use perf inside a systemd-nspawn
container. The /proc/mounts looks like this:
tmpfs /sys tmpfs
ro,nosuid,nodev,noexec,relatime,size=4096k,nr_inodes=1024,mode=555,inode64 0 0
...
sysfs /sys/block sysfs ro,nosuid,nodev,noexec,relatime 0 0
sysfs /sys/bus sysfs ro,nosuid,nodev,noexec,relatime 0 0
sysfs /sys/class sysfs ro,nosuid,nodev,noexec,relatime 0 0
sysfs /sys/dev sysfs ro,nosuid,nodev,noexec,relatime 0 0
sysfs /sys/devices sysfs ro,nosuid,nodev,noexec,relatime 0 0
sysfs /sys/kernel sysfs ro,nosuid,nodev,noexec,relatime 0 0
Perf looks for the first mount point with type "sysfs" and so concludes
sysfs is mounted at /sys/block. Thus it can't find any relevant file and
fails to detect relevant information about the system. Then it segfaults
with a null pointer dereference.
A workaround is to set SYSFS_PATH=/sys.
Apologies if this is not the right place. Perf is in the kernel source
tree so for most purposes it is a kernel bug.
** Affects: linux-hwe (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2074202
Title:
Segfault in perf (__perf_cpu_map__nr) on Linux 6.5.0-45
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-hwe/+bug/2074202/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs