[libcamera-devel] [PATCH] libcamera: log: Document LOG() restrictions

Hirokazu Honda hiroh at chromium.org
Fri May 21 11:26:55 CEST 2021


Hi Laurent, thank you for the patch.

On Fri, May 21, 2021 at 6:22 PM Laurent Pinchart <
laurent.pinchart at ideasonboard.com> wrote:

> 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 <laurent.pinchart at ideasonboard.com>
>

Reviewed-by: Hirokazu Honda <hiroh at chromium.org>


> ---
>  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
>   */
>
>  /**
> --
> Regards,
>
> Laurent Pinchart
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210521/db1042dd/attachment.htm>


More information about the libcamera-devel mailing list