[Haskell-cafe] debugging a hanging program: where to start?

Daniel Fischer daniel.is.fischer at web.de
Thu May 13 15:51:14 EDT 2010


On Thursday 13 May 2010 21:28:21, Aran Donohue wrote:
> I have an accept-loop:
>
> do (conn, _saddr) <- accept sock
>      forkIO $ initializeConnection conn
>
> Which allocates memory iff accept allocates, I suppose. To test the
> theory, is there a way I can force an allocation that won't get
> optimized away?

    t <- getCPUTime
    let n = t `rem` 12345
        s = sum [1 .. n]
    s `seq` doSomething

could work.

Another option is to insert a
    threadDelay 0
in your forever loops to enable context-switching if some other thread is 
runnable.

>
> I'm not quite sure how I ought to proceed. I'm still very open to
> debugging tools and techniques I could use to approach the problem!
>
> Aran


More information about the Haskell-Cafe mailing list