[PATCH v3 00/16] Fix signal-unsafe logging
Chase Douglas
chase.douglas at canonical.com
Mon Apr 16 11:17:07 PDT 2012
On 04/16/2012 11:14 AM, Chase Douglas wrote:
> This new patchset has some large improvements:
>
> * Variadic logging. This is done using preprocessor magic, so it is
> incompatible with the current variadic logging. It is also not type-
> safe (it could be with C11 _Generic, but only clang supports it so
> far). It also only supports up to 10 arguments. If you pass more, bad
> things might happen, but we can always increase the size as needed.
> Due to these issues and formatting limitations, I don't think we
> should switch all our logging to be signal-safe. We just have to be
> more careful with signal-safe logging.
>
> The logging is now *printf-like. However, it only supports %s, %u, %x,
> and %p (because it was trivial). I haven't see any need for %d, so I
> didn't add it. No modifiers of any sort are supported, %u and %x are
> extended to 64-bit values.
>
> The macro magic requires an ugly GCC pragma hack to turn off a
> specific warning for when casting a pointer return value of a function
> to a non-pointer value. I can't come up with a casting mechanism that
> GCC likes for all scenarios, and we are admittedly doing horrible,
> awful casting that normally would be verboten.
>
> * Added ErrorSigSafe() macro and converted all the ErrorF signal logging
> to it.
>
> * Made BUG_WARN* signal safe.
>
> * Use BUG_WARN_MSG() when logging unsafely in signal context. This logs
> the full backtrace so it is even easier to find the offending message.
>
> Unfortunately, I don't have time right now to get to unit testing. I
> must drop this work in order to get back to some Ubuntu release stuff.
I forgot again to mention that this can be found in a new branch on fdo:
http://cgit.freedesktop.org/~cndougla/xserver/log/?h=signal-logging2
-- Chase
More information about the xorg-devel
mailing list