Patch Detail
Show a patch.
GET /api/1.1/patches/21811/?format=api
{ "id": 21811, "url": "https://patchwork.libcamera.org/api/1.1/patches/21811/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21811/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241105014949.32244-3-laurent.pinchart@ideasonboard.com>", "date": "2024-11-05T01:49:49", "name": "[2/2] test: py: LD_PRELOAD the C++ standard library when using ASan", "commit_ref": "f326eb4bf26e359d980f60cfa81cc25e8347f26f", "pull_url": null, "state": "accepted", "archived": false, "hash": "22689de1ee9c95c0e61c2173211b5e9b62a2b602", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21811/mbox/", "series": [ { "id": 4768, "url": "https://patchwork.libcamera.org/api/1.1/series/4768/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4768", "date": "2024-11-05T01:49:47", "name": "test: py: Fix unit test error with ASan", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4768/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21811/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21811/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7E408C32BB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 5 Nov 2024 01:50:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B614B653EE;\n\tTue, 5 Nov 2024 02:50:01 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 18C95653E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 5 Nov 2024 02:49:59 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D02827FE;\n\tTue, 5 Nov 2024 02:49:51 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bfd8QYtF\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1730771392;\n\tbh=XqnxBXkQ0UUU3mLxrCJvi3emBttUyPiMmbLzvFM/0FY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=bfd8QYtFOvczHhERbhYP/w/iRLAgExPfYT4EzqKVTshAQWMNac+4HVysvYUwkHuUC\n\tUMm54nbfIfe5IUx0mfSvC4fqrSQZHSPektQOqrcksAXj7qCCXEJLiLCV4YOQFViEVD\n\tt5ZemuWdqxwXVLqPb9Ly4B6jkZpr1z8GCy87ZrYs=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>", "Subject": "[PATCH 2/2] test: py: LD_PRELOAD the C++ standard library when using\n\tASan", "Date": "Tue, 5 Nov 2024 03:49:49 +0200", "Message-ID": "<20241105014949.32244-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241105014949.32244-1-laurent.pinchart@ideasonboard.com>", "References": "<20241105014949.32244-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When the ASan runtime is linked using --as-needed, its dependency on the\nC++ standard library is stripped. This results to a failure to properly\nhandled exceptions when a C++ dynamically loaded .so is used, as in the\nPython unit tests that load the libcamera Python module:\n\nAddressSanitizer: CHECK failed: asan_interceptors.cpp:335 \"((__interception::real___cxa_throw)) != (0)\" (0x0, 0x0) (tid=32679)\n #0 0x7fa2f32e6c19 in CheckUnwind /var/tmp/portage/sys-devel/gcc-13.3.1_p20241025/work/gcc-13-20241025/libsanitizer/asan/asan_rtl.cpp:69\n #1 0x7fa2f330c9fd in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /var/tmp/portage/sys-devel/gcc-13.3.1_p20241025/work/gcc-13-20241025/libsanitizer/sanitizer_common/sanitizer_termination.cpp:86\n #2 0x7fa2f3247824 in __interceptor___cxa_throw /var/tmp/portage/sys-devel/gcc-13.3.1_p20241025/work/gcc-13-20241025/libsanitizer/asan/asan_interceptors.cpp:335\n #3 0x7fa2f3247824 in __interceptor___cxa_throw /var/tmp/portage/sys-devel/gcc-13.3.1_p20241025/work/gcc-13-20241025/libsanitizer/asan/asan_interceptors.cpp:334\n #4 0x7fa2efb6da8b in operator() ../../src/py/libcamera/py_main.cpp:157\n[...]\n\nThe issue has been reported in [1] and so far remains unfixed. Work\naround it by preloading the C++ standard library.\n\n[1] https://github.com/google/sanitizers/issues/934\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n meson.build | 3 +++\n test/py/meson.build | 6 ++++++\n 2 files changed, 9 insertions(+)", "diff": "diff --git a/meson.build b/meson.build\nindex 63e45465da9c..e3052260f13e 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -112,6 +112,8 @@ common_arguments = [\n c_arguments = []\n cpp_arguments = []\n \n+cxx_stdlib = 'libstdc++'\n+\n if cc.get_id() == 'clang'\n if cc.version().version_compare('<9')\n error('clang version is too old, libcamera requires 9.0 or newer')\n@@ -137,6 +139,7 @@ if cc.get_id() == 'clang'\n cpp_arguments += [\n '-stdlib=libc++',\n ]\n+ cxx_stdlib = 'libc++'\n endif\n \n cpp_arguments += [\ndiff --git a/test/py/meson.build b/test/py/meson.build\nindex 481bb481c110..b922e8578c29 100644\n--- a/test/py/meson.build\n+++ b/test/py/meson.build\n@@ -24,6 +24,12 @@ py_env.append('PYTHONPATH', pypathdir)\n if asan_enabled\n py_env.append('LD_PRELOAD', asan_runtime)\n \n+ # Preload the C++ standard library to work around a bug in ASan when\n+ # dynamically loading C++ .so modules.\n+ stdlib = run_command(cxx, '-print-file-name=' + cxx_stdlib + '.so',\n+ check : true).stdout().strip()\n+ py_env.append('LD_PRELOAD', stdlib)\n+\n # Disable leak detection as the Python interpreter is full of leaks.\n py_env.append('ASAN_OPTIONS', 'detect_leaks=0')\n endif\n", "prefixes": [ "2/2" ] }