Patch Detail
Show a patch.
GET /api/patches/18378/?format=api
{ "id": 18378, "url": "https://patchwork.libcamera.org/api/patches/18378/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18378/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20230310095126.27236-1-naush@raspberrypi.com>", "date": "2023-03-10T09:51:26", "name": "[libcamera-devel] ipa: raspberrypi: Fix crash under LTO", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "eca18b55c8b822e889f817194741a574fbce447b", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18378/mbox/", "series": [ { "id": 3798, "url": "https://patchwork.libcamera.org/api/series/3798/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3798", "date": "2023-03-10T09:51:26", "name": "[libcamera-devel] ipa: raspberrypi: Fix crash under LTO", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3798/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18378/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18378/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 7D8D8BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Mar 2023 09:51:31 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD143626A2;\n\tFri, 10 Mar 2023 10:51:30 +0100 (CET)", "from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A7E862661\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Mar 2023 10:51:28 +0100 (CET)", "by mail-wr1-x435.google.com with SMTP id r18so4488115wrx.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Mar 2023 01:51:28 -0800 (PST)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ts11-20020a5d4ecb000000b002c55efa9cbesm1686058wrv.39.2023.03.10.01.51.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 10 Mar 2023 01:51:26 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678441890;\n\tbh=zlQETCuFOucjX0qe6NOT3NOLu4uolzRRmXxqZ+0Tmtg=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=dkelUFXnUYPMfV0VCjJQuGQrMefQUwRpzGMsNBfy4aerCu5toz5mHUSpyHFcKojGh\n\tW439IsdQibsjqb/Xrnd0ABcCK7QMMZ4+MnqJF3PA99eVe9FrkIW7QGHbIA33T0OK2w\n\t2AaPiLreGkxw9Q8GPtO7i1D3+Ie74cixnIVEhQ3NKLvXoOoCIjJydx8VSTL+ZKUW9M\n\tPctEvGSa7lnbUnvWsAX1Qm/tzPrtiF8uxs4vG6ZycrsGA/s2DjXM9m+7iTvkAzbnqP\n\ttexAAtbper86SXYlASaq4n4xDnl3EGG5lQh8cHD69ZWmWUP2zlT4dV5u1aNRKuEIXa\n\tBxWCr0SItXiAg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1678441887;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=AFMMmMHsBE+gdnQZvIacaFiKKRakqOT4N4CLzRR9FN4=;\n\tb=IGFUKW1Fezm4xcTFRbnH1F779aBWCj/GQd/TZNXT7ex6NtKdV44yw7r9e71AhHNpeh\n\t/TIf86sx1q+ZC3dDY4VjCxeOQofps+LEzHbUhXL7meW5jpLllKETxuUCKIzNqrddiLQX\n\tdJ6G4oR6mah9XUUb5Y4uRa/odIaJZD+ykcGEvURHtuMWWixn3QezWeH1IgxlOfKc00ge\n\tRjZ6ThX2xJ2R2HWa1dXta7ZzOCCeu1aJykNfulqa0Ge0TfPTrfuDDM0rUgLL3YWbrvqY\n\tiHzSGxNnw49mkErfz1qZnAlM1XPgMgOU4Py2NvcEb0N+PpVP+0mnGYRhOX08bxV8l6Nt\n\tXsrw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"IGFUKW1F\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1678441887;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=AFMMmMHsBE+gdnQZvIacaFiKKRakqOT4N4CLzRR9FN4=;\n\tb=37gc+C4VOBWfXEtYRI9fS/rPLTjhFM1C51lq8HaPhCoEhfpFFBfkt0nlN/t7SescZS\n\tAj1crbEcQ4xUNYxJnKMPCpHQ2gFgWzXQYmgEFtb/qBXpFp2IGK8qDSRczy9CH+o1aLqm\n\thM4PsI8VH2clJUrWeKo9zFV8gXHPfPLoXR6VPCMtUNQ8Jawj+13LgYgj3Ht2R0vU3XNn\n\tbWtPU9MfotorkkFH63bJK2Gtp+Ox4Ngjg7yACUEU1uPQ6xplhQ1n2Q8K3JtZI0coJHHP\n\t0Ygq7vVR/SUUsDnDynGWN+oXfVbX2b2YRTmgUOiPyc6tARk+uxMR/TR0nJ29buvZ0l5D\n\tEcdg==", "X-Gm-Message-State": "AO0yUKXl0YIyostFHrGE1xWm8D2xWR7lHewXJ5NIw+C0zdXpBZXm3E57\n\t31KGwHfHE8192EAkS9KW9gdxClj39ek0S58DkjehTg==", "X-Google-Smtp-Source": "AK7set/2I+twGfuO5J24SyhEqUYgG506MfhUSeC2Fve/ONcRGZDPkbp7lmH6v0yDLO6cQSKTPfQWZQ==", "X-Received": "by 2002:a5d:6acd:0:b0:2cd:e0a8:f2de with SMTP id\n\tu13-20020a5d6acd000000b002cde0a8f2demr15428357wrw.12.1678441887620; \n\tFri, 10 Mar 2023 01:51:27 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 10 Mar 2023 09:51:26 +0000", "Message-Id": "<20230310095126.27236-1-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] ipa: raspberrypi: Fix crash under LTO", "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Cc": "Dave Jones <dave.jones@canonical.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Dave Jones <dave.jones@canonical.com>\n\nWhen compiled with LTO (the default on Ubuntu), the global static\nobjects camHelpers and algorithms cause a crash in raspberrypi_ipa_proxy\nat runtime as they're not allocated by the time the registration\nroutines execute.\n\nThis is a fairly crude fix which just converts the global static objects\ninto local static objects inside an equivalently named function.\n\nSigned-off-by: Dave Jones <dave.jones@canonical.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/cam_helper.cpp | 16 +++++++++++++---\n src/ipa/raspberrypi/controller/algorithm.cpp | 19 +++++++++++++++----\n 2 files changed, 28 insertions(+), 7 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\nindex d90ac1deda47..efe453dc6135 100644\n--- a/src/ipa/raspberrypi/cam_helper.cpp\n+++ b/src/ipa/raspberrypi/cam_helper.cpp\n@@ -9,6 +9,7 @@\n \n #include <limits>\n #include <map>\n+#include <memory>\n #include <string.h>\n \n #include \"libcamera/internal/v4l2_videodevice.h\"\n@@ -25,7 +26,16 @@ namespace libcamera {\n LOG_DECLARE_CATEGORY(IPARPI)\n }\n \n-static std::map<std::string, CamHelperCreateFunc> camHelpers;\n+namespace {\n+\n+std::map<std::string, CamHelperCreateFunc> &camHelpers()\n+{\n+\tstatic std::unique_ptr<std::map<std::string, CamHelperCreateFunc>> obj =\n+\t\tstd::make_unique<std::map<std::string, CamHelperCreateFunc>>();\n+\treturn *obj;\n+}\n+\n+} /* namespace */\n \n CamHelper *CamHelper::create(std::string const &camName)\n {\n@@ -33,7 +43,7 @@ CamHelper *CamHelper::create(std::string const &camName)\n \t * CamHelpers get registered by static RegisterCamHelper\n \t * initialisers.\n \t */\n-\tfor (auto &p : camHelpers) {\n+\tfor (auto &p : camHelpers()) {\n \t\tif (camName.find(p.first) != std::string::npos)\n \t\t\treturn p.second();\n \t}\n@@ -253,5 +263,5 @@ void CamHelper::populateMetadata([[maybe_unused]] const MdParser::RegisterMap &r\n RegisterCamHelper::RegisterCamHelper(char const *camName,\n \t\t\t\t CamHelperCreateFunc createFunc)\n {\n-\tcamHelpers[std::string(camName)] = createFunc;\n+\tcamHelpers()[std::string(camName)] = createFunc;\n }\ndiff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp\nindex 6d91ee292bd1..2650f98bee5b 100644\n--- a/src/ipa/raspberrypi/controller/algorithm.cpp\n+++ b/src/ipa/raspberrypi/controller/algorithm.cpp\n@@ -4,9 +4,10 @@\n *\n * algorithm.cpp - ISP control algorithms\n */\n-\n #include \"algorithm.h\"\n \n+#include <memory>\n+\n using namespace RPiController;\n \n int Algorithm::read([[maybe_unused]] const libcamera::YamlObject ¶ms)\n@@ -34,14 +35,24 @@ void Algorithm::process([[maybe_unused]] StatisticsPtr &stats,\n \n /* For registering algorithms with the system: */\n \n-static std::map<std::string, AlgoCreateFunc> algorithms;\n+namespace {\n+\n+static std::map<std::string, AlgoCreateFunc> &algorithms()\n+{\n+\tstatic std::unique_ptr<std::map<std::string, AlgoCreateFunc>> obj =\n+\t\tstd::make_unique<std::map<std::string, AlgoCreateFunc>>();\n+\treturn *obj;\n+}\n+\n+} /* namespace */\n+\n std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()\n {\n-\treturn algorithms;\n+\treturn algorithms();\n }\n \n RegisterAlgorithm::RegisterAlgorithm(char const *name,\n \t\t\t\t AlgoCreateFunc createFunc)\n {\n-\talgorithms[std::string(name)] = createFunc;\n+\talgorithms()[std::string(name)] = createFunc;\n }\n", "prefixes": [ "libcamera-devel" ] }