[{"id":26142,"web_url":"https://patchwork.libcamera.org/comment/26142/","msgid":"<79e566a2-1471-650a-dc5c-30dbe278af2b@ideasonboard.com>","date":"2022-12-23T16:58:02","subject":"Re: [libcamera-devel] [PATCH v1 3/4] test: py: Fix test failure\n\twhen ASan is enabled","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"HI Laurent,\n\nThank you for the patch\n\nOn 12/22/22 6:31 AM, Laurent Pinchart via libcamera-devel wrote:\n> When the address sanitizer is enabled, the Python unit tests fail due to\n> the link order runtime check as the Python interpreter is (generally)\n> not linked to ASan. Fix this by LD_PRELOAD'ing the ASan runtime. We have\n> to disable the leak detector as the Python interpreter itself leaks\n> memory, which would result in test failures.\n>\n> To LD_PRELOAD the ASan runtime, the path to the binary needs to be\n> known. gcc gives us a generic way to get the path, but that doesn't work\n> with clang as the ASan runtime file name depends on the clang version\n> and target architecture. We thus have to keep the Python test disabled\n> with ASan is enabled and libcamera is compiled with clang.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nAcked-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>   test/py/meson.build | 17 ++++++++++++++++-\n>   1 file changed, 16 insertions(+), 1 deletion(-)\n>\n> diff --git a/test/py/meson.build b/test/py/meson.build\n> index 2affdbd491a3..639f173594a8 100644\n> --- a/test/py/meson.build\n> +++ b/test/py/meson.build\n> @@ -4,14 +4,29 @@ if not pycamera_enabled\n>       subdir_done()\n>   endif\n>   \n> +# If ASan is enabled, the link order runtime check will fail as Python is not\n> +# linked to ASan. LD_PRELOAD the ASAn runtime if available, or skip the test\n> +# otherwise.\n> +\n> +if asan_runtime_missing\n> +    warning('Unable to get path to ASan runtime, Python test disabled')\n> +    subdir_done()\n> +endif\n> +\n>   pymod = import('python')\n>   py3 = pymod.find_installation('python3')\n>   \n>   pypathdir = meson.project_build_root() / 'src' / 'py'\n> +py_env = ['PYTHONPATH=' + pypathdir]\n> +\n> +if asan_enabled\n> +    # Disable leak detection as the Python interpreter is full of leaks.\n> +    py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0']\n> +endif\n>   \n>   test('pyunittests',\n>        py3,\n>        args : files('unittests.py'),\n> -     env : ['PYTHONPATH=' + pypathdir],\n> +     env : py_env,\n>        suite : 'pybindings',\n>        is_parallel : false)","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 52F58BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Dec 2022 16:58:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C8EA623B8;\n\tFri, 23 Dec 2022 17:58:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA78B62398\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Dec 2022 17:58:08 +0100 (CET)","from [IPV6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565] (unknown\n\t[IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D7F1492;\n\tFri, 23 Dec 2022 17:58:06 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671814690;\n\tbh=maCsdUid4ZT7TLXFFaTM70w3vtEJklQZ2tNkxq5dhWE=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=4EPGol+rPKiq8/w6SnyzkfD2iEuyXqLERD28rFlDk6vL7nYtwYK83pIyrema5zcCR\n\tqnyP/rjA51muZdlPYU25le0ixLj33F+39ojPpMrIDcYjmWOmmN3YXeH4zjHFnzaf/t\n\tuyMz/pCR9sBg5T8PFlo5VEPYrF26w0Tt42vTRiVo5+l6gv8Db+PJd+jtIdRpWxa17l\n\tQ1eixywS0jfh/1IOKlk9LZWChWVScTl/uQiwfWikGlqqU0zZccixvZAXP9jT7tN8zp\n\tSqccgiY1uW3oaSD1xRWaNpmoQe8gfJrjMplfztJxi/DcAOR6Nsos5j4eMeYuZO8l3U\n\tSXbesb0tpBjiA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1671814688;\n\tbh=maCsdUid4ZT7TLXFFaTM70w3vtEJklQZ2tNkxq5dhWE=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=k1hifsOKcEtj9sBZoQ1GKpO7R2E+GIryyqrlBFFRgYGium1a8CSu7phwBDLagnjwm\n\tjP/OLHgnXiHYie50ZnakC2/Xxuk/jgIuUpKujv9e/u5ARCypKikua7w4GtZoUKBV2T\n\tB1uE55xWXIjoIatVNVjwF7omub/WZXho0Lj7/iNs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"k1hifsOK\"; dkim-atps=neutral","Message-ID":"<79e566a2-1471-650a-dc5c-30dbe278af2b@ideasonboard.com>","Date":"Fri, 23 Dec 2022 22:28:02 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.5.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20221222010132.22177-1-laurent.pinchart@ideasonboard.com>\n\t<20221222010132.22177-4-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20221222010132.22177-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v1 3/4] test: py: Fix test failure\n\twhen ASan is enabled","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26150,"web_url":"https://patchwork.libcamera.org/comment/26150/","msgid":"<Y6ZHLxmPsMm11Rme@pyrite.rasen.tech>","date":"2022-12-24T00:26:23","subject":"Re: [libcamera-devel] [PATCH v1 3/4] test: py: Fix test failure\n\twhen ASan is enabled","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Thu, Dec 22, 2022 at 03:01:31AM +0200, Laurent Pinchart via libcamera-devel wrote:\n> When the address sanitizer is enabled, the Python unit tests fail due to\n> the link order runtime check as the Python interpreter is (generally)\n> not linked to ASan. Fix this by LD_PRELOAD'ing the ASan runtime. We have\n> to disable the leak detector as the Python interpreter itself leaks\n> memory, which would result in test failures.\n> \n> To LD_PRELOAD the ASan runtime, the path to the binary needs to be\n> known. gcc gives us a generic way to get the path, but that doesn't work\n> with clang as the ASan runtime file name depends on the clang version\n> and target architecture. We thus have to keep the Python test disabled\n> with ASan is enabled and libcamera is compiled with clang.\n\ns/with/when/\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  test/py/meson.build | 17 ++++++++++++++++-\n>  1 file changed, 16 insertions(+), 1 deletion(-)\n> \n> diff --git a/test/py/meson.build b/test/py/meson.build\n> index 2affdbd491a3..639f173594a8 100644\n> --- a/test/py/meson.build\n> +++ b/test/py/meson.build\n> @@ -4,14 +4,29 @@ if not pycamera_enabled\n>      subdir_done()\n>  endif\n>  \n> +# If ASan is enabled, the link order runtime check will fail as Python is not\n> +# linked to ASan. LD_PRELOAD the ASAn runtime if available, or skip the test\n\ns/ASAn/ASan/\n\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> +# otherwise.\n> +\n> +if asan_runtime_missing\n> +    warning('Unable to get path to ASan runtime, Python test disabled')\n> +    subdir_done()\n> +endif\n> +\n>  pymod = import('python')\n>  py3 = pymod.find_installation('python3')\n>  \n>  pypathdir = meson.project_build_root() / 'src' / 'py'\n> +py_env = ['PYTHONPATH=' + pypathdir]\n> +\n> +if asan_enabled\n> +    # Disable leak detection as the Python interpreter is full of leaks.\n> +    py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0']\n> +endif\n>  \n>  test('pyunittests',\n>       py3,\n>       args : files('unittests.py'),\n> -     env : ['PYTHONPATH=' + pypathdir],\n> +     env : py_env,\n>       suite : 'pybindings',\n>       is_parallel : false)","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 E6046BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 24 Dec 2022 00:26:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A332623B8;\n\tSat, 24 Dec 2022 01:26:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4049561507\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 24 Dec 2022 01:26:30 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2604:2d80:ad8a:9000:1bf9:855b:22de:3645])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C0854DD;\n\tSat, 24 Dec 2022 01:26:28 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671841591;\n\tbh=XphE8V1y9zM6NPrIVRipRB/8waxvzmL11D77TB/wg0U=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=i2Kh0SV4tlgIweamXmAfUmxFDYijC9n3Q2iGIC88xNgENJ/soCS5N1uLnEOBLSogA\n\tuko0yKM8fhwdHgHaU9G0aH8GV3IuT4l295MC7evxJZ++R5gTkm7J8izJNuqpTFkHvc\n\tnZBfSCOGHaEDGRDIze014gzax6cZ8WorQbVWp3xDYZ4/mIVJmVpYoK2HsTy/4ruHDa\n\tA5+TSmLQhhpT9ckN0z+qnjJgEGB0JJxG+LnY+C687tog/dQFR4J7bDKprds3FwngTQ\n\t7RWsh24cVflhyVh6YykXyAcfiUMTXb5jP9IfhW8UT6YrgLvafoZoukYHnXbllWntrK\n\t/YIvn9gYAxrrg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1671841589;\n\tbh=XphE8V1y9zM6NPrIVRipRB/8waxvzmL11D77TB/wg0U=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OSg1MJkqtCxvwnJhlBaekmtxoX+4a3ek5QJrljESrP/g1WoHWxaOBuURJ16mvw2bA\n\t4lz0kLR6HXKaFmh0SkX6/llpm3JOfxqfDopGmEBcjAmzPYeQE5smx6LVg1rMvChgsM\n\tpn68bIm11IYOJ6CXTIqj8qbFFTWRCzMGFjcdmI3M="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OSg1MJkq\"; dkim-atps=neutral","Date":"Fri, 23 Dec 2022 18:26:23 -0600","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<Y6ZHLxmPsMm11Rme@pyrite.rasen.tech>","References":"<20221222010132.22177-1-laurent.pinchart@ideasonboard.com>\n\t<20221222010132.22177-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20221222010132.22177-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v1 3/4] test: py: Fix test failure\n\twhen ASan is enabled","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]