Show a patch.

GET /api/1.1/patches/21873/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 21873,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/21873/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21873/",
    "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": "<20241108233415.25782-1-kieran.bingham@ideasonboard.com>",
    "date": "2024-11-08T23:34:15",
    "name": "CameraManager: Ensure we cleanup on failure",
    "commit_ref": "dcb90f13cf79d909d04dacf2cfbd256a4744347f",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "19ead5e90df1d690b041f10de693184f0464c39f",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21873/mbox/",
    "series": [
        {
            "id": 4784,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4784/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4784",
            "date": "2024-11-08T23:34:15",
            "name": "CameraManager: Ensure we cleanup on failure",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4784/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21873/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21873/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 5E0B7C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Nov 2024 23:34:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 982BD657B4;\n\tSat,  9 Nov 2024 00:34:21 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF38265474\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  9 Nov 2024 00:34:19 +0100 (CET)",
            "from charm.tail69b4.ts.net\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D11646DF;\n\tSat,  9 Nov 2024 00:34:09 +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=\"Iqv1dYJr\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731108849;\n\tbh=pqeOiyy2CmdLXV7MLW6R02YIsSMudnY2HNR4FJY75gU=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Iqv1dYJr7Ckkk2+MSlRq6M0PtZqZ517dZbO++UYDPBLaE5f+A5wx97kWp9cyDx3iy\n\tWrxYK2bEbWpt561/iX7FJoBl848Rd6D5kjlrpUZLd8J5Xnf2po28x9N+nlSga5sWF4\n\tO1qvwiupuODWp2s8HMGtp0CrDkjN9zvEHzo91A88=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH] CameraManager: Ensure we cleanup on failure",
        "Date": "Fri,  8 Nov 2024 23:34:15 +0000",
        "Message-ID": "<20241108233415.25782-1-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.47.0",
        "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": "If the CameraManager fails to initialise at startup during\nCameraManager::Private::init(), then the run() function will prepare the\nthread for operations, but the thread will immediately close without\nexecuting any cleanup.\n\nThis can leave instantiated objects such as the EventNotifier registered\nby the udev enumerator constructed in a thread which no longer exists.\nThe destructor of those objects can then fire an assertion that they are\nbeing executed from an incorrect thread while performing their cleanup.\n\nEnsure that the failure path does not result in reporting thread\nownership assertions by performing cleanup correctly on the\nCameraManager thread before it closes.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nThis is the result of debugging an awkward error on an unrelated failure\npath that caused the CameraManager to fail to construct:\n\n\"\"\"\ncamera_sensor_legacy.cpp:850 'ar0144 2-0010': The analogue crop rectangle has been defaulted to the active area size\n[1:49:26.079788375] [922]  WARN RkISP1Agc agc.cpp:46 'AeMeteringMode' parameter not found in tuning file\n[1:49:26.079829125] [922]  WARN RkISP1Agc agc.cpp:69 No metering modes read from tuning file; defaulting to matrix\n[1:49:26.080311125] [921] ERROR Camera camera_manager.cpp:350 Failed to start camera manager: No such file or directory\nFailed to start camera manager: No such file or directory\n[1:49:26.080547875] [921] ERROR Object object.cpp:252 EventNotifier can't be enabled from another thread\n[1:49:26.080582375] [921] FATAL default object.cpp:253 assertion \"false\" failed in assertThreadBound()\nBacktrace:\n/usr/lib/libcamera-base.so.0.3(_ZN9libcamera6Object17assertThreadBoundEPKc+0xe4) [0xffffa35fd884]\n/usr/lib/libcamera-base.so.0.3(_ZN9libcamera13EventNotifier10setEnabledEb+0x24) [0xffffa3601b34]\n/usr/lib/libcamera-base.so.0.3(_ZN9libcamera13EventNotifierD2Ev+0x50) [0xffffa3601bf0]\n/usr/lib/libcamera-base.so.0.3(_ZN9libcamera13EventNotifierD0Ev+0x18) [0xffffa3601cb8]\n/usr/lib/libcamera.so.0.3(_ZN9libcamera20DeviceEnumeratorUdevD2Ev+0x38) [0xffffa3798698]\n/usr/lib/libcamera.so.0.3(_ZN9libcamera20DeviceEnumeratorUdevD0Ev+0x18) [0xffffa3798738]\n/usr/lib/libcamera.so.0.3(+0x997cc) [0xffffa36d97cc]\n/usr/lib/libcamera.so.0.3(_ZN9libcamera13CameraManagerD1Ev+0x134) [0xffffa36d6f04]\n/usr/lib/libcamera.so.0.3(_ZN9libcamera13CameraManagerD0Ev+0x18) [0xffffa36d6f78]\ncam(+0x1ba60) [0xaaaad8d9ba60]\ncam(+0x8b64) [0xaaaad8d88b64]\n/usr/lib/libc.so.6(+0x284b4) [0xffffa30984b4]\n/usr/lib/libc.so.6(__libc_start_main+0x9c) [0xffffa309858c]\ncam(+0x8fb0) [0xaaaad8d88fb0]\nAborted (core dumped)\n\"\"\"\n\nWhilst the error \"No such file or directory\" reported above was out of\ntree code causing the camera manager to fail - libcamera should not then\nfail with an assertion after that while shutting down and calling\ndestructors.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/camera_manager.cpp | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 6280b2b3e485..a8b36bcea2d4 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -83,8 +83,10 @@ void CameraManager::Private::run()\n \tmutex_.unlock();\n \tcv_.notify_one();\n \n-\tif (ret < 0)\n+\tif (ret < 0) {\n+\t\tcleanup();\n \t\treturn;\n+\t}\n \n \t/* Now start processing events and messages. */\n \texec();\n",
    "prefixes": []
}