From patchwork Mon Jun 27 16:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16397 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F1982BE173 for ; Mon, 27 Jun 2022 16:46:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5F74865635; Mon, 27 Jun 2022 18:46:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656348396; bh=kEXuZcrNu1463nMF65Rmg80XyvAMNcYNZxO+Ayh6+q4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hJNgQutFwqFYaUNgERIHzYM8NKfup7i1uaU/h1I0sYmi8MqqbHZLcMuiIMmXg6AmY F1Jzoeek3l5cEuz4GyYPZsNdlwLr9D+riTWQ36xMsUypxYlqPqK+a02u3dZxO+ZC+V CTAndVAOpCB6fDzWhybckUqyu3+3wrn9oHok0R9HMHkzVGiwV12FmXJ+V3rWuL2U0g DbhJtIfP1NHb3W0/ZVIzFqL+Q1VyzQVKUBU24hPawNIQ1VRYjcl5zMOLR9fEE5xQMh BN/4UY6ArJuoARH2oFpw6jxP3XBavu7gu8I/N3vRwmp0NQMtdxVazylpJMSY0DMVA6 xWD3MffudoWRA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DC736059B for ; Mon, 27 Jun 2022 18:46:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u88VJz5L"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7D21E1C82; Mon, 27 Jun 2022 18:46:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656348394; bh=kEXuZcrNu1463nMF65Rmg80XyvAMNcYNZxO+Ayh6+q4=; h=From:To:Cc:Subject:Date:From; b=u88VJz5LwNc+azfz57uAmS+ClNtv04oqfI+F2+EKKnEIktcNe+nIHgkFzoN+c21Fy Th7gXlmCpzyXdkl6Kpz4Xx+W6rE7lTvFKYJRiJMfRve/ocCOIVjZISt4aptDGKTIFL enXsdbUkfFGzVinV9qPxFnNahVu+XTNoyXP/tVdU= To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jun 2022 19:46:12 +0300 Message-Id: <20220627164612.12049-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: base: thread: Prevent messages to thread without an event loop X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A message posted to an object bound to a thread without an event loop will never get delivered. This indicates a bug in the caller, and materializes in ways that can be hard to debug, such as a signal never being delivered. Add an assertion in Thread::postMessage() to catch this at the source. Signed-off-by: Laurent Pinchart --- src/libcamera/base/thread.cpp | 1 + 1 file changed, 1 insertion(+) base-commit: 27cc0a6b58bcca32071cb6ab96e5ee79c75031e5 diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 6bda9d1462f5..6ead1d7c12d0 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -530,6 +530,7 @@ void Thread::postMessage(std::unique_ptr msg, Object *receiver) msg->receiver_ = receiver; ASSERT(data_ == receiver->thread()->data_); + ASSERT(data_ != mainThread.data_); MutexLocker locker(data_->messages_.mutex_); data_->messages_.list_.push_back(std::move(msg));