Message ID | 20241105151232.21254-1-laurent.pinchart@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Quoting Laurent Pinchart (2024-11-05 15:12:32) > The address sanitizer (ASan) reports issues at both build time and > runtime. Enabling it in CI helps catching more issues. I'm very happy to see this! Much better to make sure this is run centrally on CI rather than hope it's run on individual developer machines. > Ideally we would enable ASan for all builds. However, a bug in gcc 12 > affects the Debian bookworm build in release mode, so ASan can't be > enabled unconditionally. To maximize test coverage, enable it in > MESON_ALL_OPTIONS and in the test-unit build, and disable it explicitly > where it causes issues. > > When build with clang, the ASan runtime needs to be separately installed > for the default clang versions shipped by Debian Bookworm and Trixie. > > The former is a dependency of the clang package, by the latter isn't. It > needs to be manually added to the Bookworm and Trixie containers as > their default clang versions rely on libclang-rt-dev. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > This causes the test-unit job of the CI pipeline to fail in the Python > bindings unit test with the libcamera master branch, see > https://gitlab.freedesktop.org/pinchartl/libcamera/-/pipelines/1304457. > The "[PATCH 0/2] test: py: Fix unit test error with ASan" series fixes > the text, see https://gitlab.freedesktop.org/pinchartl/libcamera/-/pipelines/1304469. > I will merge the fix in libcamera before pushing this patch to the CI > repository. I see that series is merged, so I think we're good to merge this patch now. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > --- > .gitlab-ci/setup-container.sh | 11 +++++++++-- > gitlab-ci.yml | 19 ++++++++++++++++--- > 2 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh > index 4e487d27e31a..d2909c7257d3 100755 > --- a/.gitlab-ci/setup-container.sh > +++ b/.gitlab-ci/setup-container.sh > @@ -94,14 +94,21 @@ archs=( amd64 ) > > declare -A components > > -# Install additional gcc versions On Debian bullseye (gcc 9) and trixie (gcc > -# 13). > +# Install additional packages on a per distribution version basis. > case $FDO_DISTRIBUTION_VERSION in > 'bullseye') > + # gcc 9 to expand compilation testing coverage. > PKGS_LIBCAMERA_RUNTIME+=( g++-9 ) > ;; > +'bookworm') > + # libclang-rt-dev for the clang ASan runtime. > + PKGS_LIBCAMERA_RUNTIME_MULTIARCH+=( libclang-rt-dev ) > + ;; > 'trixie') > + # gcc 13 to expand compilation testing coverage. > PKGS_LIBCAMERA_RUNTIME+=( g++-13 ) > + # libclang-rt-dev for the clang ASan runtime. > + PKGS_LIBCAMERA_RUNTIME_MULTIARCH+=( libclang-rt-dev ) > ;; > esac > > diff --git a/gitlab-ci.yml b/gitlab-ci.yml > index 57e7cc69c74f..ea038ecb5921 100644 > --- a/gitlab-ci.yml > +++ b/gitlab-ci.yml > @@ -13,6 +13,7 @@ variables: > KERNEL_VERSION: '6.6' > MESON_ALL_OPTIONS: >- > -D android=enabled > + -D b_sanitize=address > -D cam=enabled > -D documentation=enabled > -D gstreamer=enabled > @@ -24,6 +25,9 @@ variables: > -D tracing=enabled > -D udev=enabled > -D v4l2=true > + # clang fails to link with ASan if --no-undefined is enabled. > + MESON_CLANG_OPTIONS: >- > + -D b_lundef=false > PACKAGES: >- > ca-certificates > git > @@ -54,17 +58,17 @@ include: > .libcamera-ci.debian:11: > variables: > FDO_DISTRIBUTION_VERSION: 'bullseye' > - FDO_DISTRIBUTION_TAG: '2024-10-18.1' > + FDO_DISTRIBUTION_TAG: '2024-11-05.1' > > .libcamera-ci.debian:12: > variables: > FDO_DISTRIBUTION_VERSION: 'bookworm' > - FDO_DISTRIBUTION_TAG: '2024-10-18.1' > + FDO_DISTRIBUTION_TAG: '2024-11-05.1' > > .libcamera-ci.debian:13: > variables: > FDO_DISTRIBUTION_VERSION: 'trixie' > - FDO_DISTRIBUTION_TAG: '2024-10-18.2' > + FDO_DISTRIBUTION_TAG: '2024-11-05.1' > > .container-debian: > extends: > @@ -176,12 +180,19 @@ build-full:debian:12: > BUILD_TYPE: release > CC: gcc-12 > CXX: g++-12 > + # gcc 12.2.0 has a bug that triggers a false positive warning with ASan > + # in release builds (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562). > + # Disable the address sanitizer for now. > + MESON_OPTIONS: >- > + ${MESON_ALL_OPTIONS} > + -D b_sanitize=none > - ARCH: amd64 > BUILD_TYPE: debug > CC: clang > CXX: clang++ > MESON_OPTIONS: >- > ${MESON_ALL_OPTIONS} > + ${MESON_CLANG_OPTIONS} > -D qcam=disabled > - ARCH: amd64 > BUILD_TYPE: release > @@ -189,6 +200,7 @@ build-full:debian:12: > CXX: clang++ > MESON_OPTIONS: >- > ${MESON_ALL_OPTIONS} > + ${MESON_CLANG_OPTIONS} > -D qcam=disabled > - ARCH: armhf > - ARCH: arm64 > @@ -375,6 +387,7 @@ test-unit: > variables: > BUILD_TYPE: debug > MESON_OPTIONS: >- > + -D b_sanitize=address > -D cam=disabled > -D documentation=disabled > -D gstreamer=enabled > > base-commit: b3f48df7d9b104c88a59cf0cebc55b22d2ce368c > -- > Regards, > > Laurent Pinchart >
diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh index 4e487d27e31a..d2909c7257d3 100755 --- a/.gitlab-ci/setup-container.sh +++ b/.gitlab-ci/setup-container.sh @@ -94,14 +94,21 @@ archs=( amd64 ) declare -A components -# Install additional gcc versions On Debian bullseye (gcc 9) and trixie (gcc -# 13). +# Install additional packages on a per distribution version basis. case $FDO_DISTRIBUTION_VERSION in 'bullseye') + # gcc 9 to expand compilation testing coverage. PKGS_LIBCAMERA_RUNTIME+=( g++-9 ) ;; +'bookworm') + # libclang-rt-dev for the clang ASan runtime. + PKGS_LIBCAMERA_RUNTIME_MULTIARCH+=( libclang-rt-dev ) + ;; 'trixie') + # gcc 13 to expand compilation testing coverage. PKGS_LIBCAMERA_RUNTIME+=( g++-13 ) + # libclang-rt-dev for the clang ASan runtime. + PKGS_LIBCAMERA_RUNTIME_MULTIARCH+=( libclang-rt-dev ) ;; esac diff --git a/gitlab-ci.yml b/gitlab-ci.yml index 57e7cc69c74f..ea038ecb5921 100644 --- a/gitlab-ci.yml +++ b/gitlab-ci.yml @@ -13,6 +13,7 @@ variables: KERNEL_VERSION: '6.6' MESON_ALL_OPTIONS: >- -D android=enabled + -D b_sanitize=address -D cam=enabled -D documentation=enabled -D gstreamer=enabled @@ -24,6 +25,9 @@ variables: -D tracing=enabled -D udev=enabled -D v4l2=true + # clang fails to link with ASan if --no-undefined is enabled. + MESON_CLANG_OPTIONS: >- + -D b_lundef=false PACKAGES: >- ca-certificates git @@ -54,17 +58,17 @@ include: .libcamera-ci.debian:11: variables: FDO_DISTRIBUTION_VERSION: 'bullseye' - FDO_DISTRIBUTION_TAG: '2024-10-18.1' + FDO_DISTRIBUTION_TAG: '2024-11-05.1' .libcamera-ci.debian:12: variables: FDO_DISTRIBUTION_VERSION: 'bookworm' - FDO_DISTRIBUTION_TAG: '2024-10-18.1' + FDO_DISTRIBUTION_TAG: '2024-11-05.1' .libcamera-ci.debian:13: variables: FDO_DISTRIBUTION_VERSION: 'trixie' - FDO_DISTRIBUTION_TAG: '2024-10-18.2' + FDO_DISTRIBUTION_TAG: '2024-11-05.1' .container-debian: extends: @@ -176,12 +180,19 @@ build-full:debian:12: BUILD_TYPE: release CC: gcc-12 CXX: g++-12 + # gcc 12.2.0 has a bug that triggers a false positive warning with ASan + # in release builds (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562). + # Disable the address sanitizer for now. + MESON_OPTIONS: >- + ${MESON_ALL_OPTIONS} + -D b_sanitize=none - ARCH: amd64 BUILD_TYPE: debug CC: clang CXX: clang++ MESON_OPTIONS: >- ${MESON_ALL_OPTIONS} + ${MESON_CLANG_OPTIONS} -D qcam=disabled - ARCH: amd64 BUILD_TYPE: release @@ -189,6 +200,7 @@ build-full:debian:12: CXX: clang++ MESON_OPTIONS: >- ${MESON_ALL_OPTIONS} + ${MESON_CLANG_OPTIONS} -D qcam=disabled - ARCH: armhf - ARCH: arm64 @@ -375,6 +387,7 @@ test-unit: variables: BUILD_TYPE: debug MESON_OPTIONS: >- + -D b_sanitize=address -D cam=disabled -D documentation=disabled -D gstreamer=enabled
The address sanitizer (ASan) reports issues at both build time and runtime. Enabling it in CI helps catching more issues. Ideally we would enable ASan for all builds. However, a bug in gcc 12 affects the Debian bookworm build in release mode, so ASan can't be enabled unconditionally. To maximize test coverage, enable it in MESON_ALL_OPTIONS and in the test-unit build, and disable it explicitly where it causes issues. When build with clang, the ASan runtime needs to be separately installed for the default clang versions shipped by Debian Bookworm and Trixie. The former is a dependency of the clang package, by the latter isn't. It needs to be manually added to the Bookworm and Trixie containers as their default clang versions rely on libclang-rt-dev. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- This causes the test-unit job of the CI pipeline to fail in the Python bindings unit test with the libcamera master branch, see https://gitlab.freedesktop.org/pinchartl/libcamera/-/pipelines/1304457. The "[PATCH 0/2] test: py: Fix unit test error with ASan" series fixes the text, see https://gitlab.freedesktop.org/pinchartl/libcamera/-/pipelines/1304469. I will merge the fix in libcamera before pushing this patch to the CI repository. --- .gitlab-ci/setup-container.sh | 11 +++++++++-- gitlab-ci.yml | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) base-commit: b3f48df7d9b104c88a59cf0cebc55b22d2ce368c