bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Tom Stellard <tstellar@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
	dwarves@vger.kernel.org, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
	Hao Luo <haoluo@google.com>
Subject: Re: [PATCH] btf_encoder: Add extra checks for symbol names
Date: Thu, 21 Jan 2021 20:11:17 -0800	[thread overview]
Message-ID: <CAEf4BzZ-uU3vkMA1RPt1f2HbgaHoenTxeVadyxuLuFGwN9ntyw@mail.gmail.com> (raw)
In-Reply-To: <CA+icZUW6g9=sMD3hj5g+ZXOwE_DxfxO3SX2Tb-bFTiWnQLb_EA@mail.gmail.com>

On Thu, Jan 21, 2021 at 6:07 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Thu, Jan 21, 2021 at 9:53 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Thu, Jan 21, 2021 at 8:09 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > >
> > > On Thu, Jan 21, 2021 at 2:38 PM Arnaldo Carvalho de Melo
> > > <arnaldo.melo@gmail.com> wrote:
> > > >
> > > > Em Tue, Jan 12, 2021 at 04:27:59PM -0800, Tom Stellard escreveu:
> > > > > On 1/12/21 10:40 AM, Jiri Olsa wrote:
> > > > > > When processing kernel image build by clang we can
> > > > > > find some functions without the name, which causes
> > > > > > pahole to segfault.
> > > > > >
> > > > > > Adding extra checks to make sure we always have
> > > > > > function's name defined before using it.
> > > > > >
> > > > >
> > > > > I backported this patch to pahole 1.19, and I can confirm it fixes the
> > > > > segfault for me.
> > > >
> > > > I'm applying v2 for this patch and based on your above statement I'm
> > > > adding a:
> > > >
> > > > Tested-by: Tom Stellard <tstellar@redhat.com>
> > > >
> > > > Ok?
> > > >
> > > > Who originally reported this?
> > > >
> > >
> > > The origin was AFAICS the thread where I asked initially [1].
> > >
> > > Tom reported in the same thread in [2] that pahole segfaults.
> > >
> > > Later in the thread Jiri offered a draft of this patch after doing some tests.
> > >
> > > I have tested all diffs and v1 and v2 of Jiri's patch.
> > > ( Anyway, latest pahole ToT plus Jiri's patch did not solve my origin problem. )
> >
> > Your original problem was with DWARF5 or DWARF4? I think you mentioned
> > both at some point, but I remember I couldn't repro DWARF4 problems.
> > If you still have problems, can you start a new thread with steps to
> > repro (including Kconfig, tooling versions, etc). And one for each
> > problem, no all at the same time, please. I honestly lost track of
> > what's still not working among those multiple intertwined email
> > threads, sorry about that.
> >
>
> I love people saying "I have a (one) problem." :-).
>
> The origin was Debian kernel-team enabled BTF-debuginfo Kconfig.
>
> My main focus is to be as close to Debian's kernel-config and if this
> works well with (experimental) Linux DWARF v5 support I am a happy
> guy.

I don't know what kernel config Debian is using, that's why I'm asking
for kernel config that does cause the problem. Because the one I'm
using doesn't. But this problem can be a result of a lot of things,
specific compiler and its version, specific kernel config, who knows
what else.

>
> Do you want Nick's DWARF v5 patch-series as a base?

Arnaldo was going to figure out the DWARF v5 problem, so I'm leaving
it up to him. I'm curious about DWARF v4 problems because no one yet
reported that previously.

> Thinking of DWARF-v4?
> Use Nick's patchset or DWARF-v4 what is in Linux upstream means Linux
> v5.11-rc4+?
> What Git tree to use - Linus or one of your BPF/BTF folks?

I checked both v5.11-rc4 and the latest bpf-next with
CONFIG_DEBUG_INFO_DWARF4=y and CONFIG_DEBUG_INFO_BTF=y. I get no
warnings, everything works.

>
> What version of pahole (latest Git) etc.?

Latest pahole built from Git, yes.

But let's not do it in a backwards manner with me telling you what
works (my environment, my config), rather you telling us what
*doesn't* work (your config, your environment), so that we can try to
reproduce.

>
> - Sedat -
>
> > >
> > > So up to you Arnaldo for the credits.
> > >
> > > - Sedat -
> > >
> > > [1] https://marc.info/?t=161036949500004&r=1&w=2
> > > [2] https://marc.info/?t=161036949500004&r=1&w=2
> > >
> > > > - Arnaldo
> > > >
> > > > > -Tom
> > > > >
> > > > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > > > > ---
> > > > > >   btf_encoder.c | 8 ++++++--
> > > > > >   1 file changed, 6 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/btf_encoder.c b/btf_encoder.c
> > > > > > index 333973054b61..17f7a14f2ef0 100644
> > > > > > --- a/btf_encoder.c
> > > > > > +++ b/btf_encoder.c
> > > > > > @@ -72,6 +72,8 @@ static int collect_function(struct btf_elf *btfe, GElf_Sym *sym)
> > > > > >     if (elf_sym__type(sym) != STT_FUNC)
> > > > > >             return 0;
> > > > > > +   if (!elf_sym__name(sym, btfe->symtab))
> > > > > > +           return 0;
> > > > > >     if (functions_cnt == functions_alloc) {
> > > > > >             functions_alloc = max(1000, functions_alloc * 3 / 2);
> > > > > > @@ -730,9 +732,11 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> > > > > >             if (!has_arg_names(cu, &fn->proto))
> > > > > >                     continue;
> > > > > >             if (functions_cnt) {
> > > > > > -                   struct elf_function *func;
> > > > > > +                   const char *name = function__name(fn, cu);
> > > > > > +                   struct elf_function *func = NULL;
> > > > > > -                   func = find_function(btfe, function__name(fn, cu));
> > > > > > +                   if (name)
> > > > > > +                           func = find_function(btfe, name);
> > > > > >                     if (!func || func->generated)
> > > > > >                             continue;
> > > > > >                     func->generated = true;
> > > > > >
> > > > >
> > > >
> > > > --
> > > >
> > > > - Arnaldo

  reply	other threads:[~2021-01-22  4:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 18:40 [PATCH] btf_encoder: Add extra checks for symbol names Jiri Olsa
2021-01-12 19:20 ` Andrii Nakryiko
2021-01-12 19:47   ` Jiri Olsa
2021-01-12 20:17     ` Sedat Dilek
2021-01-13  0:27 ` Tom Stellard
2021-01-14  7:50   ` Sedat Dilek
2021-01-14 14:33     ` Tom Stellard
2021-01-14 14:39       ` Sedat Dilek
2021-01-21 13:38   ` Arnaldo Carvalho de Melo
2021-01-21 16:06     ` Sedat Dilek
2021-01-21 19:37       ` Arnaldo Carvalho de Melo
2021-01-21 20:53       ` Andrii Nakryiko
2021-01-22  2:07         ` Sedat Dilek
2021-01-22  4:11           ` Andrii Nakryiko [this message]
2021-01-28 20:00             ` [RFT] pahole 1.20 RC was " Arnaldo Carvalho de Melo
2021-01-28 20:57               ` Sedat Dilek
2021-01-28 21:11                 ` Arnaldo Carvalho de Melo
2021-01-28 22:28                   ` Sedat Dilek
2021-02-02  7:48               ` Andrii Nakryiko
2021-02-03  9:03                 ` Sedat Dilek
2021-02-03 10:23                   ` Mark Wielaard
2021-02-03 21:48                     ` Sedat Dilek
2021-02-03 23:21                       ` Andrii Nakryiko
2021-02-04  1:06                         ` Arnaldo Carvalho de Melo
2021-02-04  6:40                         ` Sedat Dilek
2021-01-21 17:37     ` Tom Stellard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEf4BzZ-uU3vkMA1RPt1f2HbgaHoenTxeVadyxuLuFGwN9ntyw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=haoluo@google.com \
    --cc=jolsa@kernel.org \
    --cc=sedat.dilek@gmail.com \
    --cc=tstellar@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).