[Haskell-cafe] Re: Debugging misbehaving multi-threaded programs

Simon Marlow marlowsd at gmail.com
Fri Jun 12 11:23:22 EDT 2009

On 11/06/2009 05:40, Evan Klitzke wrote:
> I've written a multi-threaded Haskell program that I'm trying to
> debug. Basically what's happening is the program runs for a while, and
> then at some point one of the threads goes crazy and spins the CPU
> while allocating memory; this proceeds until the system runs out of
> available memory. I can't fix this without figuring out what code is
> being executed in the loop (or at least which thread is misbehaving,
> which would narrow things down a lot).
> I was hopeful that I could compile the program with profiling support
> and then use +RTS -M100M along with some of the RTS profiling options
> and get profiling information on CPU and memory usage at the time that
> my program runs out of memory. The thinking here is that nearly all of
> the CPU time and heap space will be from the misbehaving thread, so at
> that point I could do more investigation into exactly what is
> happening. Unfortunately, this doesn't seem to work; whenever the
> program terminates due to running out of heap space, the generated
> .prof file is empty.

We fixed this recently (GHC 6.10.2):


In 6.12.1 you'll be able to use ThreadScope, our parallel profiling 
tool.  You could try it right now if you're brave enough to compile GHC 
(it needs GHC 6.11).  The ThreadScope code is here:


and shortly the Haskell Symposium paper about it will be available 
(we're just making the final corrections now).


More information about the Haskell-Cafe mailing list