[PATCH 0/4 v3] Use static buffers to log from driver signal handlers
Mark Kettenis
mark.kettenis at xs4all.nl
Fri Aug 5 02:18:10 PDT 2011
> From: Daniel Kurtz
> Date: Fri, 5 Aug 2011 15:09:57 +0800
>
> For Version 3:
> * 0001: Make cleaner and faster per Guillem Jover review comments.
> * 0002: Make slightly faster and fix some comments.
>
> Back in the bad old days, using xf86Msg() from a signal handler was a
> big no-no, as it would deadlock the system on malloc when the prefix is
> prepended. Thus, only X_NONE messages could be used to bypass this.
> However, LogVWrite limits to 1024 bytes anyway, so a patch was made to
> eliminate malloc in LogVMessageVerb().
I think this diff is misguided. LogVMessageVerb() still calls
snprintf(), which is *not* async-signal-safe. And, no, this is not a
theoretical issue. In many C libraries the code to print
floating-point numbers is based on gdtoa, which calls malloc().
> However, input driver messages these days go through xf86VIDrvMsgVerb(),
> which does its own asprintf()/mallocs() to prefix the driver and device
> names, reintroducing the same old no-no.
The input drivers should really not try to print messages from signal
handlers.
More information about the xorg-devel
mailing list