[GHC] #9395: Debug.Trace should not use %s for format string
GHC
ghc-devs at haskell.org
Sun Aug 3 20:44:45 UTC 2014
#9395: Debug.Trace should not use %s for format string
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: bug | Status: new
Priority: normal | Milestone:
Component: | Version: 7.8.2
libraries/base | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: Incorrect | Related Tickets:
result at runtime |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by ezyang):
OK, it's a little trickier than just specifying a new format string; I
forgot that
{{{
#include "stdio.h"
int main() {
printf("%.*s", 4, "AA\0B");
return 0;
}
}}}
only outputs AA, even with the length description. So we can't use
debugBelch. This raises the question, why are we using debugBelch at all?
Some archaeology later:
{{{
[project @ 2005-01-28 23:33:57 by krasimir]
- The output from uncaught exceptions handler is redirected to RTS's
errorBelch.
- The output from Debug.Trace is redirected to RTS's debugBelch
- Usually errorBelch and debugBelch messages go to stderr except for
Windows GUI applications. For GUI applications the Debug.Trace output is
redirected to debug console and the exceptions message is displayed in
message box.
}}}
It also seems like a good idea generally to bypass Haskell-lands
buffering. Unfortunately, printf style output is a hard-coded assumption
for `RtsMsgFunction`, so we can't easily swap it out without introducing
another function for raw output.
Maybe, alternately, Debug.Trace should munge out null bytes?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9395#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list