traceEvent truncates to 512 bytes
The Debug.Trace.traceEvent (& traceEventIO) use a code path that unnecessarily uses printf format strings and uses a fixed size 512-byte buffer, hence truncating all user trace messages at that size.
Here is the call path:
-
Debug.Trace.traceEvent(&traceEventIO) calltraceEvent#primop - cmm impl of the primop
stg_traceEventzhcalls C RTS functiontraceUserMsg -
traceUserMsgcallstraceFormatUserMsg(cap, "%s", msg);, using the printf format string -
traceFormatUserMsgusespostUserMsgwhich eventually callspostLogMsg -
postLogMsgdoes the printf stuff
Here's what postLogMsg does:
#define BUF 512
void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap)
{
char buf[BUF];
nat size;
size = vsnprintf(buf,BUF,msg,ap);
if (size > BUF) {
buf[BUF-1] = '\0';
size = BUF;
}
....
This is obviously designed for RTS-internal users, not the user path.
So the problem starts with this bit:
void traceUserMsg(Capability *cap, char *msg)
{
traceFormatUserMsg(cap, "%s", msg);
}
It just should not use that code path. It should call something that directly posts the message, without any silly printf strings. In fact, the code path from the primop down should really be changed to use an explicit given length, rather than using a null-terminated string and having to call strlen.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |