bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>, Julia Kartseva <hex@fb.com>
Subject: Re: [PATCH bpf-next 2/6] selftests/bpf: add test_progs-asan flavor with AddressSantizer
Date: Tue, 28 Apr 2020 13:41:55 -0700	[thread overview]
Message-ID: <20200428204155.ycancp6xg2yfisnh@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <CAEf4Bza7mK8FH0S9S6Jqi37JQFdLjdbeU6u6QiAosoOiVdEMTA@mail.gmail.com>

On Tue, Apr 28, 2020 at 11:35:15AM -0700, Andrii Nakryiko wrote:
> On Tue, Apr 28, 2020 at 9:44 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Mon, Apr 27, 2020 at 09:46:24PM -0700, Andrii Nakryiko wrote:
> > > Add another flavor of test_progs that is compiled and run with
> > > AddressSanitizer and LeakSanitizer. This allows to find potential memory
> > > correction bugs and memory leaks. Due to sometimes not trivial requirements on
> > > the environment, this is (for now) done as a separate flavor, not by default.
> > > Eventually I hope to enable it by default.
> > >
> > > To run ./test_progs-asan successfully, you need to have libasan installed in
> > > the system, where version of the package depends on GCC version you have.
> > > E.g., GCC8 needs libasan5, while GCC7 uses libasan4.
> > >
> > > For CentOS 7, to build everything successfully one would need to:
> > >   $ sudo yum install devtoolset-8-gcc devtoolset-libasan-devel
> > >
> > > For Arch Linux to run selftests, one would need to install gcc-libs package to
> > > get libasan.so.5:
> > >   $ sudo pacman -S gcc-libs
> > >
> > > Cc: Julia Kartseva <hex@fb.com>
> > > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> >
> > It needs a feature check.
> > selftest shouldn't be forcing asan on everyone.
> > Even after I did:
> > sudo yum install devtoolset-8-libasan-devel
> > it still failed to build:
> >   BINARY   test_progs-asan
> > /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find libasan_preinit.o: No such file or directory
> > /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -lasan
> >
> 
> Yeah, it worked for me initially because it still used GCC7 locally
> and older version of libasan.
> 
> On CentOS you have to run the following command to set up environment
> (for current session only, though):
> 
> $ scl enable devtoolset-8 bash
> 
> What it does:
> - adds /opt/rh/devtoolset-8/root/usr/bin to $PATH
> - sets $LD_LIBRARY_PATH to
> /opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib

I don't want to do this, since I prefer gcc9 for my builds since it has better warnings.
But yum cannot find devtoolset-9-libasan-devel it seems.

> I'm going to add this to patch to ease some pain later. But yeah, I
> think I have a better plan for ASAN builds. I'll add EXTRA_CFLAGS to
> selftests Makefile, defaulted to nothing. Then for Travis CI (or
> locally) one would do:
> 
> $ make EXTRA_CFLAGS='-fsanitize-address'
> 
> to build ASAN versions of all the same test runners (including
> test_verifier, test_maps, etc).
> 
> I think this will be better overall.
> 
> > Also I really don't like that skeletons are now built three times for now good reason
> >   GEN-SKEL [test_progs-asan] test_stack_map.skel.h
> >   GEN-SKEL [test_progs-asan] test_core_reloc_nesting.skel.h
> > default vs no_alu32 makes sense. They are different bpf.o files and different skeletons,
> > but for asan there is no such need.
> 
> I agree, luckily I don't really have to change anything with the above approach.
> 
> >
> > Please resubmit the rest of the patches, since asan isn't a prerequisite.
> 
> I'll update this patch to just add EXTRA_CFLAGS, if you are ok with
> this (and will leave instructions on installing libasan).

yeah. EXTRA_CFLAGS approach should work.
That will build both test_progs and test_progs-no_alu32 with libasan ?
That would be ideal.

  reply	other threads:[~2020-04-28 20:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  4:46 [PATCH bpf-next 0/6] Add ASAN to selftest and fix found problems Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 1/6] selftests/bpf: ensure test flavors use correct skeletons Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 2/6] selftests/bpf: add test_progs-asan flavor with AddressSantizer Andrii Nakryiko
2020-04-28 16:44   ` Alexei Starovoitov
2020-04-28 18:35     ` Andrii Nakryiko
2020-04-28 20:41       ` Alexei Starovoitov [this message]
2020-04-28 22:13         ` Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 3/6] selftests/bpf: convert test_hashmap into test_progs test Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 4/6] libbpf: fix memory leak and possible double-free in hashmap__clear Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 5/6] selftests/bpf: fix memory leak in test selector Andrii Nakryiko
2020-04-28  4:46 ` [PATCH bpf-next 6/6] selftests/bpf: fix memory leak in extract_build_id() Andrii Nakryiko

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=20200428204155.ycancp6xg2yfisnh@ast-mbp.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hex@fb.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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).