Filter out null bytes from trace, and warn accordingly, fixing #9395.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Tue, 5 Aug 2014 16:55:00 +0000 (09:55 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Tue, 5 Aug 2014 17:50:33 +0000 (10:50 -0700)
commitd360d440b994c03d645603c50f25ef208700db02
tree9c1d515daa6e6a67a0e199fb585f0680c79ce0ed
parent56ca32c96d82489cb28d7bfa13432ae00ac20cb1
Filter out null bytes from trace, and warn accordingly, fixing #9395.

Summary:
Previously, if you ran trace "foo\0bar", the output was truncated so
that everything after the null byte was omitted.  This was terrible.
Now we filter out null bytes, and emit an extra trace saying that
null bytes were filtered out.

NB: we CANNOT fix debugBelch, because all printf variants *always*
respect null bytes, even if you're using string precision such as
%.*s.  The alternative would have been to introduce a new function
debugRawBelch which did not use format strings and took an explicit
string length, but I decided we generally should avoid putting null
bytes in our trace messages, and warn the user.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: hvr, austin

Subscribers: simonmar, relrod, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D121

GHC Trac Issues: #9395
libraries/base/Debug/Trace.hs
libraries/base/tests/T9395.hs [new file with mode: 0644]
libraries/base/tests/T9395.stderr [new file with mode: 0644]
libraries/base/tests/all.T