From patchwork Tue Nov 5 15:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21814 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id EDC64BDB1C for ; Tue, 5 Nov 2024 15:12:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F472653F5; Tue, 5 Nov 2024 16:12:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="je0uEvtc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 65BEF6035B for ; Tue, 5 Nov 2024 16:12:40 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 66C02874 for ; Tue, 5 Nov 2024 16:12:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730819552; bh=vMBdSGF4NNnAcKf7FOY1LJik2PUt4U5nyWu5tbyKkPE=; h=From:To:Subject:Date:From; b=je0uEvtcrfj/AIQnSjoO4d6u+O59X6gCl1rodjPIjW1ZtApfJpXi0b8bRZyJHDVSK mVbCijAh/PQ4Ywp5xnXRo6rE9um7AFLnTrt6TA4eA6qNqqiU7IwphSETX1peavZUoF Y98eUH/u1NoWgxr5LK1Wuu5PdGWgfHk5Cfsw2a7E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] [CI] Enable ASan wherever possible Date: Tue, 5 Nov 2024 17:12:32 +0200 Message-ID: <20241105151232.21254-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Kieran Bingham --- 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 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