BPF List
 help / color / mirror / Atom feed
From: Kui-Feng Lee <sinquersw@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: size_t :0 doesn't always work with llvm-16
Date: Sat, 28 Oct 2023 18:42:21 -0700	[thread overview]
Message-ID: <0c188e9e-a01d-495f-9aa9-d7bf72275f45@gmail.com> (raw)
In-Reply-To: <CAEf4BzbZ=2KueQo6BErkS+M2TAov7Q0SbsBmV=3iL2m5ZFCvEA@mail.gmail.com>



On 10/28/23 18:12, Andrii Nakryiko wrote:
> On Sat, Oct 28, 2023 at 5:52 PM Kui-Feng Lee <sinquersw@gmail.com> wrote:
>>
>> Recently, while running the test_maps, I encountered an error
>> message. Upon further investigation, I discovered that llvm-16 behaves
>> inconsistently when it comes to clearing partially initialized local
>> variables.
>>
>> We appends a 'size_t :0' at the end of many types to prevent dirty
>> bytes at the end of struct types.  libbpf also check dirty padding
>> bytes for CORE. It works most of time with gcc and llvm.  However, I
>> have discovered that it is not always work with llvm. The C
>> specification does not guarantee this either. Nonetheless, we
>> primarily rely on gcc and llvm. In most cases, on x86_64 platforms,
>> llvm utilizes memset() to clear a partially initialized variable of a
>> struct type.
>>
> 
> Yes, which is why using LIBBPF_OPTS() is a good idea. And which is why
> I submitted [0] to fix this in our test_maps tests. I'll resend this
> fix outside of BPF token series.
> 
>    [0] https://patchwork.kernel.org/project/netdevbpf/patch/20231016180220.3866105-14-andrii@kernel.org/

Great to hear that!
Thanks!

      reply	other threads:[~2023-10-29  1:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29  0:52 size_t :0 doesn't always work with llvm-16 Kui-Feng Lee
2023-10-29  1:12 ` Andrii Nakryiko
2023-10-29  1:42   ` Kui-Feng Lee [this message]

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=0c188e9e-a01d-495f-9aa9-d7bf72275f45@gmail.com \
    --to=sinquersw@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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