[libcamera-devel] [PATCH] test: v4l2_compat: Disable test when ASan is enabled

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Sep 1 11:09:37 CEST 2021


Hi Paul,

On Tue, Aug 31, 2021 at 12:33:05PM +0900, Paul Elder wrote:
> On Fri, Aug 27, 2021 at 11:50:12PM +0300, Laurent Pinchart wrote:
> > The V4L2 compat test runs v4l2-ctl and v4l2-compliance with
> > v4l2-compat.so preloaded. If libcamera is compiled with the address
> > sanitizer enabled, the ASan library will be loaded due to preloading
> > v4l2-compat.so. This however doesn't occur early enough in the dynamic
> > linking process due to the v4l2 executables not being themselves linked
> > to the ASan runtime, which causes ASan to abort with
> > 
> > ==2198==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
> > 
> > Using LD_PRELOAD to load the ASan runtime would fix this issue, but it
> > requires knowing the absolute path to the ASan shared object. This is
> > compiler-dependent and for clang, architecture-dependent as well.
> > 
> > Until we figure out how to safely retrieve that information, disable the
> > test when ASan is enabled as a quick fix.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> >  test/v4l2_compat/meson.build | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/test/v4l2_compat/meson.build b/test/v4l2_compat/meson.build
> > index 5b29de7c0805..4164e9f945ee 100644
> > --- a/test/v4l2_compat/meson.build
> > +++ b/test/v4l2_compat/meson.build
> > @@ -1,5 +1,11 @@
> >  # SPDX-License-Identifier: CC0-1.0
> >  
> > +# If ASan is enabled, the link order runtime check will fail as v4l2-ctl and
> > +# v4l2-compliance are not linked to ASan. Skip the test in that case.
> 
> Should we put a todo?

I think so.

# TODO: Find a way to LD_PRELOAD the ASan dynamic library instead, in a
# cross-platform way with support for both gcc and clang.

> With or without,
> 
> Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
> 
> > +if get_option('b_sanitize').contains('address')
> > +    subdir_done()
> > +endif
> > +
> >  if is_variable('v4l2_compat')
> >      v4l2_compat_test = files('v4l2_compat_test.py')
> >  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list