summaryrefslogtreecommitdiff
path: root/os/log.c
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-04-06 08:32:28 -0700
committerKeith Packard <keithp@keithp.com>2012-07-02 22:34:32 -0700
commit82d1c6b310eaa5095eed9ee4ea958261a46a78e1 (patch)
tree9cb1e3857669a53f7f35e5a2d448144265cb6439 /os/log.c
parent512bec06be6c79ca263da9de8f40430b8095b57b (diff)
Warn when attempting to log in a signal unsafe manner from signal context
Also, print out the offending message format. This will hopefully help developers track down unsafe logging. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os/log.c')
-rw-r--r--os/log.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/os/log.c b/os/log.c
index 47ba34876..25da9f63a 100644
--- a/os/log.c
+++ b/os/log.c
@@ -463,6 +463,16 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
Bool newline;
size_t len = 0;
+ if (inSignalContext) {
+ BUG_WARN_MSG(inSignalContext,
+ "Warning: attempting to log data in a signal unsafe "
+ "manner while in signal context. Please update to check "
+ "inSignalContext and/or use LogMessageVerbSigSafe() or "
+ "ErrorFSigSafe(). The offending log format message is:\n"
+ "%s\n", format);
+ return;
+ }
+
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
return;
@@ -552,6 +562,16 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
Bool newline;
size_t len = 0;
+ if (inSignalContext) {
+ BUG_WARN_MSG(inSignalContext,
+ "Warning: attempting to log data in a signal unsafe "
+ "manner while in signal context. Please update to check "
+ "inSignalContext and/or use LogMessageVerbSigSafe(). The "
+ "offending header and log message formats are:\n%s %s\n",
+ hdr_format, msg_format);
+ return;
+ }
+
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
return;