Patch Detail
Show a patch.
GET /api/1.1/patches/19432/?format=api
{ "id": 19432, "url": "https://patchwork.libcamera.org/api/1.1/patches/19432/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19432/", "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": "<20240121035948.4226-12-laurent.pinchart@ideasonboard.com>", "date": "2024-01-21T03:59:47", "name": "[libcamera-devel,11/12] libcamera: object: Document and ensure Object deletion constraints", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3a9d3f9b9819506795a1f29fd6da67e8c9ab0c25", "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/19432/mbox/", "series": [ { "id": 4149, "url": "https://patchwork.libcamera.org/api/1.1/series/4149/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4149", "date": "2024-01-21T03:59:36", "name": "libcamera: Hardening against thread race conditions", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4149/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19432/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19432/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 7F935C32C0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jan 2024 04:00:07 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C74DF62950;\n\tSun, 21 Jan 2024 05:00:06 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FFAE62956\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jan 2024 05:00:00 +0100 (CET)", "from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 64B931574;\n\tSun, 21 Jan 2024 04:58:48 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705809606;\n\tbh=z0BmluV3+ys9PMdaTdconxWAgym5vmaEG5yZyDHy/JY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=mUQshlTdBbOxXt9/Smd1UutBnz6RfatQ6z3PnnUdYJxQtSFlBrg1IUBpR+SYpjJel\n\tHKLtv2Co6IQ7YNk2Zr8YSpGJRKhJd81oNX754uTiIAV4mVn/zYMysRMBer9b3kxBMV\n\tU1iRBCkpjtCdHmabARKpWiXbk5+ahw0vDn8vTOLq6PKzHSQLna8ClLtwdh8izNNgcI\n\tIjPBiZX9r5vIgC51pzWf957mHMlWzkzpG6aJk7/Ev/+e1TBguPRftrFPRgx88jp2Pn\n\tgjUGoIFlTosIvmb0e1osr7Qc5U5I9EsC++ebefgyiRk4Ii80dDhNOLjICeiKLJWg8P\n\tk08wdZMfTZEsw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1705809528;\n\tbh=z0BmluV3+ys9PMdaTdconxWAgym5vmaEG5yZyDHy/JY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JVivAXNBa2vCimQqNH+EM2ADe9pJdqZHPqYoYJa3WFzHhWmYcnxT1emcAecFm5AqR\n\tm2KVNydz3Tcp224eWOUdniNXamYqQasLNPvUSqCzQWr9FsfV10A4mIC5P24x8MTgKI\n\tvZH7p195MjkFFcWs1rpvhfhHfdz0VzMqVohA+HqU=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JVivAXNB\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 21 Jan 2024 05:59:47 +0200", "Message-ID": "<20240121035948.4226-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240121035948.4226-1-laurent.pinchart@ideasonboard.com>", "References": "<20240121035948.4226-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 11/12] libcamera: object: Document and\n\tensure Object deletion constraints", "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Object instances are meant to be deleted from the thread they are bound\nto, and this requirement is documented. There are however exceptions to\nthe rule, as threads may be stopped and restarted, with objects bound to\nthem not being deleted and recreated for every stop/restart cycle. Bound\nobjects may therefore need to be deleted after the thread has stopped,\nmaking it impossible to use Object::deleteLater().\n\nDocument the lifetime requirements more precisely, and enforce them with\nan assertion.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/base/object.cpp | 16 ++++++++++++++--\n 1 file changed, 14 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp\nindex 1fce5a2af9af..8af0337f5448 100644\n--- a/src/libcamera/base/object.cpp\n+++ b/src/libcamera/base/object.cpp\n@@ -40,8 +40,9 @@ LOG_DEFINE_CATEGORY(Object)\n * Object class.\n *\n * Deleting an object from a thread other than the one the object is bound to is\n- * unsafe, unless the caller ensures that the object isn't processing any\n- * message concurrently.\n+ * unsafe, unless the caller ensures that the object's thread is stopped and no\n+ * parent or child of the object gets deleted concurrently. See\n+ * Object::~Object() for more information.\n *\n * Object slots connected to signals will also run in the context of the\n * object's thread, regardless of whether the signal is emitted in the same or\n@@ -84,9 +85,20 @@ Object::Object(Object *parent)\n * Object instances shall be destroyed from the thread they are bound to,\n * otherwise undefined behaviour may occur. If deletion of an Object needs to\n * be scheduled from a different thread, deleteLater() shall be used.\n+ *\n+ * As an exception to this rule, Object instances may be deleted from a\n+ * different thread if the thread the instance is bound to is stopped through\n+ * the whole duration of the object's destruction, *and* the parent and children\n+ * of the object do not get deleted concurrently. The caller is responsible for\n+ * fulfilling those requirements.\n+ *\n+ * In all cases Object instances shall be deleted before the Thread they are\n+ * bound to.\n */\n Object::~Object()\n {\n+\tASSERT(Thread::current() == thread_ || !thread_->isRunning());\n+\n \t/*\n \t * Move signals to a private list to avoid concurrent iteration and\n \t * deletion of items from Signal::disconnect().\n", "prefixes": [ "libcamera-devel", "11/12" ] }