[PATCH 0/6] Fix signal-unsafe logging

Chase Douglas chase.douglas at canonical.com
Fri Apr 6 11:25:53 PDT 2012


During signal context we may only call signal-safe functions. The list
of safe functions can be found in the POSIX signal(7) man page. If you
call a signal unsafe function in signal context you may cause memory,
lock, or other corruption.

In particular, I can't run the X server under valgrind to diagnose
issues in signal context that also happen to log messages. Valgrind is
very strict about signal context, and it causes a segfault as soon as
ErrorF is hit, for example.

This patch set ensures that logging is always signal context safe. It
triggers a warning if a normal logging function is used from signal
context because all the existing logging is *printf style. There is no
signal-safe way of doing *printf outside of rolling your own
implementation. In fact, on Ubuntu sprintf() is the function that causes
valgrind to segfault.

It then adds LogMessageVerbSigSafe() to log a static string. An unsigned
number formatting routine has been added to help with typical printing
use cases.

Finally, two known signal context logging paths have been fixed to use
LogMessageVerbSigSafe().

Because corruption can occur, I suggest this be applied to the 1.12
stable series as well. However, I don't know for sure that corruption is
occurring, so it's not a clear cut candidate.


More information about the xorg-devel mailing list