[MLton-user] profile bug

Matthew Fluet fluet at tti-c.org
Sat Dec 1 10:25:11 PST 2007


On Sat, 1 Dec 2007, Sean McLaughlin wrote:
>  I'm linking to some c++ code, and found what I suspect to be a bug
> with mlprof.  I don't know
> what's happening, but when a destructor is called on a static class member,
> mlprof won't work.  The example is attached.

mlprof runs the program that was profiled with the argument
'@MLton show-sources --' to get some additional (static) profiling 
information that isn't saved to the mlmon.out file.  This information is 
printed to stdout, and mlprof validates that the information format 
matches its expectations.  (In particular, that there is nothing on stdout 
after mlprof reads all its expected data.)

In your example, the destructor on the "static errorWrapup Ewrapup" runs 
when the program terminates after being invoked by mlprof; the destructor 
prints to stdout, and mlprof (rightly) complains because the output from 
'@MLton show-sources --' includes more than it expects.

You could try directing your destructor messages to stderr, rather than 
stdout.  You'll get some spurious output when mlprof runs (since it 
doesn't redirect stderr when it invokes the profiled program).

You could also recompile mlprof and omit the check that stdout is empty 
after reading all the expected data (<src>/mlprof/main.sml:186).  But, 
that is slightly dangerous.  For example, if you add stdout output to 
constructors of static objects, then that output will appear before the 
expected information from '@MLton show-sources -', and you would be hard 
pressed to fix mlprof to find the beginning of the expected info.



More information about the MLton-user mailing list