Bugs item #973063, was opened at 2004-06-15 08:14
Message generated for change (Comment added) made by simonmar
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=973063&group_id=8032
Category: libraries/base
Group: 6.2.1
>Status: Closed
>Resolution: Fixed
Priority: 4
Submitted By: Simon Marlow (simonmar)
Assigned to: Simon Marlow (simonmar)
Summary: DiffArray deadlock
Initial Comment:
Posted to [EMAIL PROTECTED], by Lauri Alanko
[EMAIL PROTECTED]:
The following program gets stuck in ghci, and when
compiled with ghc and
run, fails with "Fail: thread blocked indefinitely".
import Data.Array.Diff
main = print (a // [((a ! 0, 1))] ! 0)
where a = array (0,0) [(0,0)] :: DiffArray Int Int
When DiffArray is replaced with Array, it just prints
out "1" as it
should.
Apparently there is some kind of a deadlock internally,
with the update
operation holding the lock already before the lookup
operation is
evaluated.
I think the solution is to evaluate all the indices in
the argument to
replaceDiffArray _before_ obtaining the lock. Changing
a single line in
Diff.hs gives a partial quick fix:
@@ -287 +287 @@
-a `replaceDiffArray` ies = do
+a `replaceDiffArray` ies = sum (map fst ies) `seq` do
However, in DiffUArray, when the underlying imperative
array is unboxed,
the operation is strict also in the elements, and then
(and _only_ then)
the elements, too, need to be evaluated before the MVar
is taken, or
otherwise their evaluation may lead to a deadlock.
I'm not really sure what would be the neatest solution.
Lauri Alanko
[EMAIL PROTECTED]
----------------------------------------------------------------------
>Comment By: Simon Marlow (simonmar)
Date: 2004-08-23 11:57
Message:
Logged In: YES
user_id=48280
Fixed, thanks.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=973063&group_id=8032
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs