On 10/28/23 18:12, Andrii Nakryiko wrote:
On Sat, Oct 28, 2023 at 5:52 PM Kui-Feng Lee <sinquersw@xxxxxxxxx> 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@xxxxxxxxxx/
Great to hear that!
Thanks!