From patchwork Tue Jan 14 14:36:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 22560 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 6C691C3303 for ; Tue, 14 Jan 2025 14:36:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7EF6B607D6; Tue, 14 Jan 2025 15:36:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ABUyHqYN"; 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 9E427607D6 for ; Tue, 14 Jan 2025 15:36:27 +0100 (CET) Received: from pendragon.ideasonboard.com (unknown [193.209.96.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 233BE465 for ; Tue, 14 Jan 2025 15:35:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1736865330; bh=jriLsmOADQLj3IwSeTk6Wj2CHqEx/8G3dXW+urNuvss=; h=From:To:Subject:Date:From; b=ABUyHqYNfTSgD4ThszvMhiIYWRKX7wEfQaspJpD0g852zlLtnt2TXPaSgCCCLThHF wXC+bzLh95k4WEpmeUHWyNwurB1LL+v2Iwvp5MpfgZgFIP3SK/6Qk1qkAWBB/gwYOM lVznkMVbxJBdgkGzjukPjxuFWV0hxTgGa+qgqeDM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: v4l2_subdevice: Work around false positive warning Date: Tue, 14 Jan 2025 16:36:22 +0200 Message-ID: <20250114143622.28803-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" gcc 13.3.0, as provided by buildroot 2024.11.1, chokes when compiling v4l2_subdevice.cpp with ASan enabled, due to the usage of the C++ standard library regex header: In file included from /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/functional:59, from ../../include/libcamera/base/utils.h:12, from ../../include/libcamera/base/log.h:15, from ../../include/libcamera/internal/v4l2_subdevice.h:20, from ../../src/libcamera/v4l2_subdevice.cpp:8: In constructor ‘std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]’, inlined from ‘std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:149:4, inlined from ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:281:24: /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/std_function.h:405:42: error: ‘*(std::function*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State::.std::__detail::_State_base::)).std::function::_M_invoker’ may be used uninitialized [-Werror=maybe-uninitialized] 405 | : _Function_base(), _M_invoker(__x._M_invoker) | ~~~~^~~~~~~~~~ In file included from /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/regex:65, from ../../src/libcamera/v4l2_subdevice.cpp:11: /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h: In member function ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits]’: /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:279:17: note: ‘__tmp’ declared here 279 | _StateT __tmp(_S_opcode_subexpr_begin); | ^~~~~ In member function ‘bool std::_Function_base::_M_empty() const’, inlined from ‘std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = bool; _ArgTypes = {char}]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/std_function.h:574:25, inlined from ‘std::function<_Res(_ArgTypes ...)>::function(std::function<_Res(_ArgTypes ...)>&&) [with _Res = bool; _ArgTypes = {char}]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/std_function.h:407:6, inlined from ‘std::__detail::_State<_Char_type>::_State(std::__detail::_State<_Char_type>&&) [with _Char_type = char]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:149:4, inlined from ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11::regex_traits]’ at /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:281:24: /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/std_function.h:247:37: error: ‘*(const std::_Function_base*)((char*)&__tmp + offsetof(std::__detail::_StateT, std::__detail::_State::.std::__detail::_State_base::)).std::_Function_base::_M_manager’ may be used uninitialized [-Werror=maybe-uninitialized] 247 | bool _M_empty() const { return !_M_manager; } | ^~~~~~~~~~ /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h: In member function ‘std::__detail::_StateIdT std::__detail::_NFA<_TraitsT>::_M_insert_subexpr_begin() [with _TraitsT = std::__cxx11: /host/aarch64-buildroot-linux-gnu/include/c++/13.3.0/bits/regex_automaton.h:279:17: note: ‘__tmp’ declared here 279 | _StateT __tmp(_S_opcode_subexpr_begin); | ^~~~~ This is a false positive that previously occurred with gcc 12.1.0 and was fixed in 12.2 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562), and it seems to have now reappeared. The bug report indicates that the probability of such false positives increase when using sanitizers. As this isn't caught by CI, which compiles libcamera with gcc 13.3.0, the chance that such compilation failures will appear in environments without a clear pattern is relatively high. Work around the problem by disabling the warning around the inclusiong of the regex header. If the regex header needs to be included in other source files, creating a wrapped in libcamera-base may be a cleaner alternative. Signed-off-by: Laurent Pinchart --- src/libcamera/v4l2_subdevice.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) base-commit: 2ae7b2ff7438a4deecff2a8b5de685cc14e5cd44 diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 7a064d87da41..33279654db8c 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -8,12 +8,18 @@ #include "libcamera/internal/v4l2_subdevice.h" #include -#include #include #include #include #include +#pragma GCC diagnostic push +#if defined __SANITIZE_ADDRESS__ && defined __OPTIMIZE__ +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif +#include +#pragma GCC diagnostic pop + #include #include