Patch Detail
Show a patch.
GET /api/patches/18379/?format=api
{ "id": 18379, "url": "https://patchwork.libcamera.org/api/patches/18379/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18379/", "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": "<20230310113911.30842-1-naush@raspberrypi.com>", "date": "2023-03-10T11:39:11", "name": "[libcamera-devel,v2] ipa: raspberrypi: Fix crash under LTO", "commit_ref": "afc5ea57b496c633a1a16c67cf132df6c5ed9b46", "pull_url": null, "state": "accepted", "archived": false, "hash": "f3d74ab106c30f815ea1a0cae887e38d3d213789", "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/18379/mbox/", "series": [ { "id": 3799, "url": "https://patchwork.libcamera.org/api/series/3799/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3799", "date": "2023-03-10T11:39:11", "name": "[libcamera-devel,v2] ipa: raspberrypi: Fix crash under LTO", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3799/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18379/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18379/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 71936BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Mar 2023 11:39:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A408D626C5;\n\tFri, 10 Mar 2023 12:39:12 +0100 (CET)", "from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BC45603B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Mar 2023 12:39:10 +0100 (CET)", "by mail-wm1-x329.google.com with SMTP id\n\tt25-20020a1c7719000000b003eb052cc5ccso5779957wmi.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Mar 2023 03:39:10 -0800 (PST)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t4-20020a05600c024400b003e2096da239sm2706389wmj.7.2023.03.10.03.39.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 10 Mar 2023 03:39:09 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678448352;\n\tbh=KVVx+zPzvlfOxsO8zlIx4Nr2HHOXITXdbjYKFMboXNs=;\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=cYKTIsdwjDZEK7TA2jq9AjUMbCn8SOnUV1IDLbA7Q9ver4HxmrNyxf5fATbZ+88hN\n\tRAKHVzJWinxO0r4DvN2FR7j7qbKdrkIRKSERFz+U7JjuYP5+DdV/7GawH8Z9jrkHKt\n\thjG75ghXDc+vbu67pC8682KmSQxzP9qSi1jDRKS0m3pHCqlJIIOf3z5ULxnAvXJrUj\n\ttIzE3S1xv57ecSJocrUs1rc5R1Et+HC7kL3nU7BxeZCeJKKzm7GASfwPln02TY6F1w\n\tSOS3cMfqOlvKOia0z/in29/8CAgcweEFnTrJGyDk5Oc75/vveLKYoXSsJ7Xlk9kILG\n\t9DGq/EBOvv3Xw==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1678448350;\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=9XQ6KhTL4PCbVABYwrsAcUl+kxKFDislxrgLWNXk3jQ=;\n\tb=tkEoCDStbYrvmfV9ZmEQpoeA+SFcwNjYiVHpcouoBdHbYIi/Eh+XDT/NRDCDnGo//e\n\tWlspoPwb8eetP8ACpHz93EZtb8qlE1AbJTJZ/Baj9o5p03lF4iau8c+El+AJLbox8SbT\n\tOPF0HFeuzvsIyAk3Unl+zI8ewUWaHpE4JQH4NsSDTHHBUnygpQ8aYcE9CUlODGNMsC9p\n\tN/z+lwPJJSUkSR1TgywrrS48RAWZ0943yoXY6bv40pvoUgLvNj3P/9ck9tr7H307U6Xs\n\tbPPRpJe5vGq6QOxTEe2v5lQ9l5C9RMEScAnLv5UdFYSv1WkU8Jye07CLexoxBPXw8NKk\n\tVjVg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"tkEoCDSt\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1678448350;\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=9XQ6KhTL4PCbVABYwrsAcUl+kxKFDislxrgLWNXk3jQ=;\n\tb=aWSoT0RfL72dt8hKvZfACOxJntQt6CkEkSyTRy8NcYbGTRbwkD7i6Em9jGE159phC5\n\tw468F+2XoyiTuOGveuhUBVOV/XYalrOqpoEYZ0Ru+RWydI4fjtn3PRg6OW13sufZJWFV\n\tLkAuZlNWRx53VLf8n1HCyH8jQuz7wssio7U7DUwtVxnxqjNUD5Kf+/VIEiosxFng+G2J\n\tZuDevUFB7LAMi1tAZOAlXSDyMojwOeDAoKYRf+Z+35NUb34aYuyj9dPKvExqwG2yN/li\n\tPDHudfZEhjS14DF2x0w2z/WTeGL6Z2KR4W/gvrNHzgPYex5NAknQSpgVHlfcVA0OBYEM\n\t8nJQ==", "X-Gm-Message-State": "AO0yUKV1b0Qi6F4i51odlo2bDPPhFb3vjxOUN8rhB5MJvPsZkb5VaoEa\n\tA8B9dBOhaOlecUryrEd98hBdBcdVP2Ds3G2ZdItlDg==", "X-Google-Smtp-Source": "AK7set924wU3pfCzfGRs75Y310TWN0Wjo3Z75iDzVCvVNMeduMx0u1/0IXRsjrJ/5s2pE4vOX8osgw==", "X-Received": "by 2002:a05:600c:4453:b0:3eb:389d:156c with SMTP id\n\tv19-20020a05600c445300b003eb389d156cmr2366988wmn.37.1678448349783; \n\tFri, 10 Mar 2023 03:39:09 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 10 Mar 2023 11:39:11 +0000", "Message-Id": "<20230310113911.30842-1-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2] 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 | 14 +++++++++++---\n src/ipa/raspberrypi/controller/algorithm.cpp | 15 ++++++++++++---\n 2 files changed, 23 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\nindex d90ac1deda47..ddd5e9a4fef2 100644\n--- a/src/ipa/raspberrypi/cam_helper.cpp\n+++ b/src/ipa/raspberrypi/cam_helper.cpp\n@@ -25,7 +25,15 @@ 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::map<std::string, CamHelperCreateFunc> helpers;\n+\treturn helpers;\n+}\n+\n+} /* namespace */\n \n CamHelper *CamHelper::create(std::string const &camName)\n {\n@@ -33,7 +41,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 +261,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..a957fde520c2 100644\n--- a/src/ipa/raspberrypi/controller/algorithm.cpp\n+++ b/src/ipa/raspberrypi/controller/algorithm.cpp\n@@ -34,14 +34,23 @@ 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-std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()\n+namespace {\n+\n+std::map<std::string, AlgoCreateFunc> &algorithms()\n {\n+\tstatic std::map<std::string, AlgoCreateFunc> algorithms;\n \treturn algorithms;\n }\n \n+} /* namespace */\n+\n+std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()\n+{\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", "v2" ] }