From patchwork Fri May 21 09:22:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12337 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 E082DC31FF for ; Fri, 21 May 2021 09:22:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 47C9D6891D; Fri, 21 May 2021 11:22:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oOZ1nZBY"; dkim-atps=neutral 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 B672468918 for ; Fri, 21 May 2021 11:22:19 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 21A37ACC; Fri, 21 May 2021 11:22:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1621588939; bh=+JlwVUT4m9rbsp4a2GIHOFld6fO4vzJtWsBHCAZQScE=; h=From:To:Cc:Subject:Date:From; b=oOZ1nZBYWSzU3No0gygHLw9xXcYFpPh7oF6/QZvdzw6nJb/GudevfZYJ0nsIJUI4X 7BZjoiFifT7BWBChu5xtOn09/Y/+kwT5jxasFi/hJpZbNDr5vdA+eZuTaNVNKSBECH +ZoPsxvYKJ3SrGq4o95RsunMjrqVXuV24ZFRyHQg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 21 May 2021 12:22:14 +0300 Message-Id: <20210521092214.1160-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: log: Document LOG() restrictions 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The LOG() macro uses the global Logger and LogCategory objects internally. This can result in crashes or other undefined behaviour when logging from destructors of global objects, as the Logger and/or the LogCategory instances may have been destroyed. This isn't ideal and should eventually be fixed. For the time being, document the restriction, and add a todo list item to fix the problem. Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/libcamera/log.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index 94175ab34535..985952249289 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -980,6 +980,12 @@ LogMessage _log(const LogCategory *category, LogSeverity severity, * * If the severity is set to Fatal, execution is aborted and the program * terminates immediately after printing the message. + * + * \warning Logging from the destructor of a global object, either directly or + * indirectly, results in undefined behaviour. + * + * \todo Allow logging from destructors of global objects to the largest + * possible extent */ /**