Show a patch.

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

{
    "id": 24102,
    "url": "https://patchwork.libcamera.org/api/patches/24102/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24102/",
    "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": "<20250814093138.2075098-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-08-14T09:31:38",
    "name": "[v1] libcamera: base: semaphore: Do not unlock prematurely",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "48b3a70f3925c3f062f2e87f692a6197518387b1",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24102/mbox/",
    "series": [
        {
            "id": 5374,
            "url": "https://patchwork.libcamera.org/api/series/5374/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5374",
            "date": "2025-08-14T09:31:38",
            "name": "[v1] libcamera: base: semaphore: Do not unlock prematurely",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5374/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24102/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24102/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 5FFA7BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Aug 2025 09:31:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B8196924F;\n\tThu, 14 Aug 2025 11:31:43 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E219861436\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Aug 2025 11:31:41 +0200 (CEST)",
            "from pb-laptop.local (185.221.141.188.nat.pool.zt.hu\n\t[185.221.141.188])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A335B83D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Aug 2025 11:30:47 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"S/FOyU83\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755163847;\n\tbh=I0/DirPIgO38PUMSqdQ03zf+CJIFSEKX1wvPLrmXlgw=;\n\th=From:To:Subject:Date:From;\n\tb=S/FOyU83ocvAjLlKbRYKmuY5nMRpXZFpEhxp8SmOOTcqg+949P6a8T84RoSbyJ8AF\n\tVgvpZnVIlQ87PyQQs3fQgtIOBdnU0pzMBwp8G3RGej7yH+bGYYE7xjcUsQK4PBL/07\n\tBSzrE833WCP2DiSuPPao3FkSckKgDLALqe4uXhzM=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v1] libcamera: base: semaphore: Do not unlock prematurely",
        "Date": "Thu, 14 Aug 2025 11:31:38 +0200",
        "Message-ID": "<20250814093138.2075098-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.50.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "In `Semaphore::release()`, unlocking the mutex before signalling the condition\nvariable can be problematic, especially with \"temporary\" objects such as the\nones `BoundMethodBase::activatePack()` uses to handle `ConnectionTypeBlocking`.\n\nSpecifically, `Semaphore::acquire()` might lock the mutex after `Semaphore::release()`\nhas unlocked it, but before it had the chance to notify the condition variable.\nIn that case `Semaphore::acquire()` can succeed, and execution may proceed to\ndestroy the `Semaphore` object while the other thread is in the process of\nrunning `std::condition_variable::notify_all()`.\n\nSee [0] for essentially the same issue in libcxx and its fix at [1].\n\n[0]: https://github.com/llvm/llvm-project/issues/23667\n[1]: https://github.com/llvm/llvm-project/commit/b3ec43d78aa2599e1592392844a7ec638fab7902\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=225\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/base/semaphore.cpp | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/libcamera/base/semaphore.cpp b/src/libcamera/base/semaphore.cpp\nindex 862f3b313..6aec8b92d 100644\n--- a/src/libcamera/base/semaphore.cpp\n+++ b/src/libcamera/base/semaphore.cpp\n@@ -93,11 +93,9 @@ bool Semaphore::tryAcquire(unsigned int n)\n  */\n void Semaphore::release(unsigned int n)\n {\n-\t{\n-\t\tMutexLocker locker(mutex_);\n-\t\tavailable_ += n;\n-\t}\n+\tMutexLocker locker(mutex_);\n \n+\tavailable_ += n;\n \tcv_.notify_all();\n }\n \n",
    "prefixes": [
        "v1"
    ]
}