[Haskell-cafe] semantics of concurrent program depends on -O level, -f[no-]omit-yields

Ian Denhardt ian at zenhack.net
Thu Nov 29 20:52:06 UTC 2018


Quoting Johannes Waldmann (2018-11-29 13:42:42)

> These differences already occur with the
> last two lines replaced by "forever $ return ()",
> so the STM stuff may be inessential here.
> But that's the context where I came across the problem.

There's another thread right now with a subject line of "Timing out a
pure evaluation of an expression I did not write myself," that seems
like it might be related: I would expect forever $ return () to not
allocate, which would mean it would never hit any yields, and thus never
be rescheduled, and hogging the CPU.

I've been able to reproduce your results, and if I change the last line
to:

    forever $ do
        yield
        atomically $ writeTVar x True

..it always prints -- so the culprit is definitely a failure to yield.

-Ian


More information about the Haskell-Cafe mailing list