Re: [GHC] #13615: Nondeterminism in ‘pure’ function w/ parallel evaluation & memo combinators

GHC ghc-devs at haskell.org
Thu Apr 27 01:58:59 UTC 2017


#13615: Nondeterminism in ‘pure’ function w/ parallel evaluation & memo combinators
-------------------------------------+-------------------------------------
        Reporter:  pacak             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.2.1-rc2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by bgamari):

 So perhaps we are entering a closure twice and consequently get a race
 condition where one thread in-place increments a hashtable entry by `x`,
 then the other does the same, but uses the now already incremented
 hashtable, resulting in an overall contribution of `2*x`. This explains
 why the hashtable sum is always larger than the expected result.

 While it's not clear precisely what closure we are entering multiple
 times, the fix is clear: ensure that `unordered-containers` is compiled
 with `-feager-blackholing`. However, we should also (at very least)
 document this caveat better. The users-guide current advertises `-feager-
 blackholing` as a optimization to avoid redundant computation in parallel
 programs. However, in this case that it's absolutely critical for
 correctness.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13615#comment:20>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list