On Tue, Nov 19, 2024 at 12:59:58PM +0000, Alan Maguire wrote: > On 18/11/2024 20:41, Arnaldo Carvalho de Melo wrote: > > From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > > > > On a system without any debugging info or when one specifies BTF as the > > only BTF info desired but no BTF is available (or invalidated using > > PAHOLE_VMLINUX_BTF_FILENAME to an invalid/non-existent file), we're > > getting a segfault: > > > > root@x1:/home/acme/git/pahole# export PAHOLE_VMLINUX_BTF_FILENAME=non-existent > > root@x1:/home/acme/git/pahole# pahole --running_kernel_vmlinux > > pahole: couldn't find a vmlinux that matches the running kernel > > HINT: Maybe you're inside a container or missing a debuginfo package? > > root@x1:/home/acme/git/pahole# pahole > > Segmentation fault (core dumped) > > root@x1:/home/acme/git/pahole# > > > > So add a test that checks for that before we fix it: > > > > root@x1:/home/acme/git/pahole# tests/default_vmlinux_btf.sh > > Default BTF on a system without BTF: FAILED > > root@x1:/home/acme/git/pahole# > > > > Reported-by: Matthias Schwarzott <zzam@xxxxxxxxxx> > > Cc: Alan Maguire <alan.maguire@xxxxxxxxxx> > > Cc: Andrii Nakryiko <andrii@xxxxxxxxxx> > > Cc: Eduard Zingerman <eddyz87@xxxxxxxxx> > > Cc: Jiri Olsa <jolsa@xxxxxxxxxx> > > Cc: Song Liu <song@xxxxxxxxxx> > > Cc: Yonghong Song <yonghong.song@xxxxxxxxx> > > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> Thanks, added to the cset, - Arnaldo > > --- > > tests/default_vmlinux_btf.sh | 21 +++++++++++++++++++++ > > 1 file changed, 21 insertions(+) > > create mode 100755 tests/default_vmlinux_btf.sh > > > > diff --git a/tests/default_vmlinux_btf.sh b/tests/default_vmlinux_btf.sh > > new file mode 100755 > > index 0000000000000000..a9effa2d6d37e0ee > > --- /dev/null > > +++ b/tests/default_vmlinux_btf.sh > > @@ -0,0 +1,21 @@ > > +#!/bin/bash > > + > > +echo -n "Default BTF on a system without BTF: " > > + > > +ulimit -c 0 > > + > > +# To suppress the "Segmentation fault core dumped" message in bash we > > +# pipe it to some other command, if it segfaults it will not produce any > > +# lines and thus we can infer from the number of lines that the segfault > > +# took place, tricky, but couldn't find any other way to check this > > +# while suppressing the core dumped message. -acme > > + > > +nr_lines=$(PAHOLE_VMLINUX_BTF_FILENAME=foobar pahole -F btf list_head 2>&1 | wc -l) > > + > > +if [ $nr_lines -eq 0 ] ; then > > + echo "FAILED" > > + exit 1 > > +fi > > + > > +echo "Ok" > > +exit 0