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

Aran Donohue aran.donohue at gmail.com
Thu May 13 16:51:06 EDT 2010


The memory allocation / threadDelay 0 has no effect, so it isn't *that*
 bug.

I've noticed something new, too. I have some other sleeping threads in the
system. When those sleep for short threadDelays compared to the frequency of
accepts, the problem is accelerated. However when the other threads have
threadDelays that go longer than the accept frequency, the problem doesn't
seem to occur.

That is, it seems that having pending thread-awakenings prevents the issue.
I'm stumped!

On Thu, May 13, 2010 at 3:51 PM, Daniel Fischer <daniel.is.fischer at web.de>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100513/da1fe689/attachment.html


More information about the Haskell-Cafe mailing list