[PATCH 4/6] Warn when attempting to log in a signal unsafe manner from signal context

Chase Douglas chase.douglas at canonical.com
Fri Apr 6 11:33:04 PDT 2012


On 04/06/2012 11:25 AM, Chase Douglas wrote:
> Also, print out the offending message format. This will hopefully help
> developers track down unsafe logging.
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  os/log.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/os/log.c b/os/log.c
> index 840439a..88ab1d7 100644
> --- a/os/log.c
> +++ b/os/log.c
> @@ -288,6 +288,21 @@ LogVWrite(int verb, const char *f, va_list args)
>      int len = 0;
>      static Bool newline = TRUE;
>  
> +    if (inSignalContext) {
> +        static const char warning[] = "Warning: attempting to log data in a "
> +                                      "signal unsafe manner while in signal "
> +                                      "context. Please update to use "
> +                                      "xf86InSignalContext() and/or "

I forgot to update this to reference the inSignalContext global var
instead of the xf86InSignalContext, which I realized would not work as I
originally intended.

I have already fixed this in my tree. I'm assuming this will go through
another version, so I'll wait until then to fix it.

> +                                      "LogMessageVerbSigSafe(). The offending "
> +                                      "log format message is:\n";
> +
> +        write(logFileFd, warning, sizeof(warning) - 1);
> +
> +        write(logFileFd, f, strlen_sigsafe(f));
> +
> +        return;
> +    }
> +
>      if (newline) {
>          sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
>          len = strlen(tmpBuffer);



More information about the xorg-devel mailing list