Show a patch.

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

{
    "id": 2347,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2347/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2347/",
    "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": "<20191124003917.10887-1-laurent.pinchart@ideasonboard.com>",
    "date": "2019-11-24T00:39:17",
    "name": "[libcamera-devel] libcamera: thread: Fix locking when moving object",
    "commit_ref": "f88e756ceac9a442f12de5d2913047ed40b34542",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "307962fb385c09367c0153cbd4040b9c54c6a396",
    "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/2347/mbox/",
    "series": [
        {
            "id": 578,
            "url": "https://patchwork.libcamera.org/api/1.1/series/578/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=578",
            "date": "2019-11-24T00:39:17",
            "name": "[libcamera-devel] libcamera: thread: Fix locking when moving object",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/578/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2347/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2347/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D3B376136E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Nov 2019 01:39:30 +0100 (CET)",
            "from pendragon.ideasonboard.com (fs96f9c64d.tkyc509.ap.nuro.jp\n\t[150.249.198.77])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FB9B310\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Nov 2019 01:39:29 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1574555970;\n\tbh=3qCxK6afobXzAXH4iDSpMZbHYauW1BhOxg6qI1/qt60=;\n\th=From:To:Subject:Date:From;\n\tb=V8kYLb59NK/Gq/uXp5BMvRGW/SjPXWLFsHWquNEOHdQI5g1oUNKSH29ZnjHOZewBV\n\tooROBgalLYH0H8nTt/QYfUsubBo46yehyaICXKSuGx3FNwHePzdg/d/xZ/6zoHrKWk\n\t3hviI4r+4vpIzTHrO1tn65ZjDERGRA5PGuvm1F8k=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 24 Nov 2019 02:39:17 +0200",
        "Message-Id": "<20191124003917.10887-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: thread: Fix locking when\n\tmoving object",
        "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>",
        "X-List-Received-Date": "Sun, 24 Nov 2019 00:39:31 -0000"
    },
    "content": "When moving an Object to a Thread, messages posted for the object are\nmove to the target thread's message queue. This requires locking the\nmessage queues of the current and target threads, as the target thread\nmay (and is usually) running. The implementation is faulty as it locks\nthe thread data instead of the message queue. This creates a race\ncondition with a tiny but exploitable time window.\n\nThe issue was noticed by the event-thread test rarely but reproducibly\nfailing with the following assertion error:\n\n[1:39:33.850878042]FATAL default thread.cpp:440 assertion \"data_ == receiver->thread()->data_\" failed\n\nThe issue only occurred when libcamera was compiled in release mode,\nfurther hinting of a race condition.\n\nFixes: 01b930964acd (\"libcamera: thread: Add a messaging passing API\")\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/thread.cpp | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex e152af14631e..029a0e8fddd5 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -456,8 +456,8 @@ void Thread::moveObject(Object *object)\n \tThreadData *currentData = object->thread_->data_;\n \tThreadData *targetData = data_;\n \n-\tMutexLocker lockerFrom(currentData->mutex_, std::defer_lock);\n-\tMutexLocker lockerTo(targetData->mutex_, std::defer_lock);\n+\tMutexLocker lockerFrom(currentData->messages_.mutex_, std::defer_lock);\n+\tMutexLocker lockerTo(targetData->messages_.mutex_, std::defer_lock);\n \tstd::lock(lockerFrom, lockerTo);\n \n \tmoveObject(object, currentData, targetData);\n",
    "prefixes": [
        "libcamera-devel"
    ]
}