Ticket #3874: 3874-1.patch

File 3874-1.patch, 1.8 KB (added by cjs, 3 years ago)

Fix segfaults with eventlog user messages due to bad va_args. These were due to bad va_args, either because the default configuration was bad, or because we tried to interpret rather than ignore printf format strings in the user messages.

  • rts/Trace.c

    diff --git a/rts/Trace.c b/rts/Trace.c
    index a26a919..81b43f7 100644
    a b  
    278278    va_end(ap); 
    279279} 
    280280 
    281 void traceUserMsg(Capability *cap, char *msg) 
     281static void traceFormatUserMsg(Capability *cap, char *msg, ...) 
    282282{ 
     283    va_list ap; 
     284    va_start(ap,msg); 
    283285#ifdef DEBUG 
    284286    if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { 
    285         traceCap_stderr(cap, msg, NULL); 
     287        traceCap_stderr(cap, msg, ap); 
    286288    } else 
    287289#endif 
    288290    { 
    289291        if (eventlog_enabled) { 
    290             postUserMsg(cap, msg); 
     292            postUserMsg(cap, msg, ap); 
    291293        } 
    292294    } 
     295    va_end(ap); 
     296} 
     297 
     298void traceUserMsg(Capability *cap, char *msg) 
     299{ 
     300    traceFormatUserMsg(cap, "%s", msg); 
    293301} 
    294302 
    295303void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG) 
  • rts/eventlog/EventLog.c

    diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
    index 65eff8a..4f6141e 100644
    a b  
    428428    postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap); 
    429429} 
    430430 
    431 void postUserMsg(Capability *cap, char *msg) 
     431void postUserMsg(Capability *cap, char *msg, va_list ap) 
    432432{ 
    433     postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, NULL); 
     433    postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap); 
    434434}     
    435435 
    436436void closeBlockMarker (EventsBuf *ebuf) 
  • rts/eventlog/EventLog.h

    diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
    index 557ee77..224cd04 100644
    a b  
    3333 
    3434void postMsg(char *msg, va_list ap); 
    3535 
    36 void postUserMsg(Capability *cap, char *msg); 
     36void postUserMsg(Capability *cap, char *msg, va_list ap); 
    3737 
    3838void postCapMsg(Capability *cap, char *msg, va_list ap); 
    3939