Commit 91bfa780 authored by Simon Marlow's avatar Simon Marlow

Fix crash when using printf format specifiers in traceEvent (#3874)

parent b1b95df6
......@@ -299,21 +299,29 @@ void trace_(char *msg, ...)
va_end(ap);
}
void traceUserMsg(Capability *cap, char *msg)
static void traceFormatUserMsg(Capability *cap, char *msg, ...)
{
va_list ap;
va_start(ap,msg);
#ifdef DEBUG
if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
traceCap_stderr(cap, msg, NULL);
traceCap_stderr(cap, msg, ap);
} else
#endif
{
if (eventlog_enabled) {
postUserMsg(cap, msg);
postUserMsg(cap, msg, ap);
}
}
dtraceUserMsg(cap->no, msg);
}
void traceUserMsg(Capability *cap, char *msg)
{
traceFormatUserMsg(cap, "%s", msg);
}
void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG)
{
#ifdef DEBUG
......
......@@ -448,9 +448,9 @@ void postCapMsg(Capability *cap, char *msg, va_list ap)
postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap);
}
void postUserMsg(Capability *cap, char *msg)
void postUserMsg(Capability *cap, char *msg, va_list ap)
{
postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, NULL);
postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap);
}
void closeBlockMarker (EventsBuf *ebuf)
......
......@@ -39,7 +39,7 @@ void postEvent(Capability *cap, EventTypeNum tag);
void postMsg(char *msg, va_list ap);
void postUserMsg(Capability *cap, char *msg);
void postUserMsg(Capability *cap, char *msg, va_list ap);
void postCapMsg(Capability *cap, char *msg, va_list ap);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment