Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi, I am working on a library I'd like to release to hackage very soon, but I've found a problem with supporting GHC 6.12 and GHC 7.0. Consider the following program: import Control.Concurrent import Data.Typeable main :: IO () main = do { fin1 <- newEmptyMVar ; fin2 <- newEmptyMVar

Re: Is this a concurrency bug in base?

2011-10-09 Thread Daniel Fischer
On Sunday 09 October 2011, 13:52:47, Jean-Marie Gaillourdet wrote: > This seems to be a Heisenbug as it is extremely fragile, when adding a > "| grep 1" to the while loop it seems to disappears. At least on my > computers. Still produces 1s here with a grep. > > All this was done on several Mac

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi Daniel, On 09.10.2011, at 14:45, Daniel Fischer wrote: > On Sunday 09 October 2011, 13:52:47, Jean-Marie Gaillourdet wrote: >> This seems to be a Heisenbug as it is extremely fragile, when adding a >> "| grep 1" to the while loop it seems to disappears. At least on my >> computers. > > Still

Re: Is this a concurrency bug in base?

2011-10-09 Thread Daniel Fischer
On Sunday 09 October 2011, 15:30:20, Jean-Marie Gaillourdet wrote: > Hi Daniel, > > On 09.10.2011, at 14:45, Daniel Fischer wrote: > > On Sunday 09 October 2011, 13:52:47, Jean-Marie Gaillourdet wrote: > >> This seems to be a Heisenbug as it is extremely fragile, when adding > >> a "| grep 1" to t

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi, the Eq instance of TypeRep shows the same non-deterministic behavior: import Control.Concurrent import Control.Exception import Control.Monad import Data.Typeable main :: IO () main = do { fin1 <- newEmptyMVar ; fin2 <- newEmptyMVar ; forkIO $ return (typeOf ()) >>= evaluate >>= pu

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi Daniel, On 09.10.2011, at 16:24, Daniel Fischer wrote: > On Sunday 09 October 2011, 15:30:20, Jean-Marie Gaillourdet wrote: >> Hi Daniel, >> >> On 09.10.2011, at 14:45, Daniel Fischer wrote: >>> On Sunday 09 October 2011, 13:52:47, Jean-Marie Gaillourdet wrote: This seems to be a Heise

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
On 09.10.2011, at 16:40, Jean-Marie Gaillourdet wrote: > I will report a bug. http://hackage.haskell.org/trac/ghc/attachment/ticket/5540/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/

Re: Is this a concurrency bug in base?

2011-10-09 Thread Daniel Fischer
Jean-Marie Gaillourdet: > the Eq instance of TypeRep shows the same non-deterministic behavior: Of course, equality on TypeReps is implemented by comparison of the Keys. On Sunday 09 October 2011, 16:40:13, Jean-Marie Gaillourdet wrote: > Hi Daniel, > I've been chasing the source of the non-dete

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi, On 09.10.2011, at 17:27, Daniel Fischer wrote: > Jean-Marie Gaillourdet: >> the Eq instance of TypeRep shows the same non-deterministic behavior: > > Of course, equality on TypeReps is implemented by comparison of the Keys. > > On Sunday 09 October 2011, 16:40:13, Jean-Marie Gaillourdet wro

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
Hi, On 09.10.2011, at 17:37, Jean-Marie Gaillourdet wrote: > Hi, > > On 09.10.2011, at 17:27, Daniel Fischer wrote: > >> That's what I expect. >> I think what happens is: >> >> -- from Data.Typeable >> >> cache = unsafePerformIO $ ... >> >> >> mkTyConKey :: String -> Key >> mkTyConKey str

Re: Is this a concurrency bug in base?

2011-10-09 Thread wagnerdm
Quoting Jean-Marie Gaillourdet : That sounds plausible. Do you see any workaround? Perhaps repeatedly evaluating typeOf? If there's a concurrency bug, surely the workaround is to protect calls to the non-thread-safe function with a lock. typeOfWorkaround lock v = do () <- take

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
On 09.10.2011, at 17:56, wagne...@seas.upenn.edu wrote: > Quoting Jean-Marie Gaillourdet : > >> That sounds plausible. Do you see any workaround? Perhaps repeatedly >> evaluating typeOf? > > If there's a concurrency bug, surely the workaround is to protect calls to > the non-thread-safe funct

Re: Is this a concurrency bug in base?

2011-10-09 Thread Daniel Fischer
On Sunday 09 October 2011, 17:51:06, Jean-Marie Gaillourdet wrote: > > That sounds plausible. Do you see any workaround? Perhaps repeatedly > > evaluating typeOf? > > typeOf' seems to be a working workaround: > > typeOf' val > | t1 == t2 = t1 > | otherwise = typeOf' val > where > t

Re: Is this a concurrency bug in base?

2011-10-09 Thread Jean-Marie Gaillourdet
On 09.10.2011, at 18:13, Daniel Fischer wrote: > On Sunday 09 October 2011, 17:51:06, Jean-Marie Gaillourdet wrote: >>> That sounds plausible. Do you see any workaround? Perhaps repeatedly >>> evaluating typeOf? >> >> typeOf' seems to be a working workaround: >> >> typeOf' val >>| t1 == t2

Re: Is this a concurrency bug in base?

2011-10-09 Thread David Brown
On Sun, Oct 09, 2011 at 03:30:20PM +0200, Jean-Marie Gaillourdet wrote: Hi Daniel, On 09.10.2011, at 14:45, Daniel Fischer wrote: On Sunday 09 October 2011, 13:52:47, Jean-Marie Gaillourdet wrote: This seems to be a Heisenbug as it is extremely fragile, when adding a "| grep 1" to the while l

RE: Is this a concurrency bug in base?

2011-10-10 Thread Simon Peyton-Jones
October 2011 12:53 To: glasgow-haskell-users Subject: Is this a concurrency bug in base? Hi, I am working on a library I'd like to release to hackage very soon, but I've found a problem with supporting GHC 6.12 and GHC 7.0. Consider the following program: import Control.Concurr

Re: Is this a concurrency bug in base?

2011-10-10 Thread Simon Marlow
.org [mailto:glasgow-haskell-users-boun...@haskell.org] *On Behalf Of *Jean-Marie Gaillourdet *Sent:* 09 October 2011 12:53 *To:* glasgow-haskell-users *Subject:* Is this a concurrency bug in base? Hi, I am working on a library I'd like to release to hackage very soon, but I've found a proble

Re: Is this a concurrency bug in base?

2011-10-11 Thread Jean-Marie Gaillourdet
Hi, I've continued my search for a proper workaround. Again, I did find some unexpected results. See below. On 09.10.2011, at 17:56, wagne...@seas.upenn.edu wrote: > Quoting Jean-Marie Gaillourdet : > >> That sounds plausible. Do you see any workaround? Perhaps repeatedly >> evaluating typeO

RE: Is this a concurrency bug in base?

2011-10-12 Thread Simon Peyton-Jones
: wagne...@seas.upenn.edu; Daniel Fischer Cc: glasgow-haskell-users@haskell.org Subject: Re: Is this a concurrency bug in base? Hi, I've continued my search for a proper workaround. Again, I did find some unexpected results. See below. On 09.10.2011, at 17:56, wagne...@seas.upenn.edu

Re: Is this a concurrency bug in base?

2011-10-12 Thread Bertram Felgenhauer
Jean-Marie Gaillourdet wrote: > This is my previous program with your workaround, it is also attached as > TypeRepEqLock.hs > [snip] > Compile and execute: > > $ ghc-7.0.3 -threaded -rtsopts TypeRepEqLock.hs > > $ while true ; do ./TypeRepEqLock +RTS -N ; done > Ok > Ok > Ok > Ok > Ok > Ok > Ok

Re: Is this a concurrency bug in base?

2011-10-12 Thread Jean-Marie Gaillourdet
Hi Simon, On 12.10.2011, at 10:34, Simon Peyton-Jones wrote: > Did you try 7.2? As I mentioned, the issue should have gone away entirely > because there is no shared cache any more Yes, I did test it with GHC 7.2. And yes, with GHC 7.2 typeOf is fine. I continued to look into that issue bec

Re: Is this a concurrency bug in base?

2011-10-12 Thread Jean-Marie Gaillourdet
Hi Bertram, On 12.10.2011, at 13:24, Bertram Felgenhauer wrote: > This has nothing to do with Data.Typeable though - it appears to be some > interaction between unsaferPerformIO and MVars that I do not understand. > The following program occasionally terminates with "thread blocked > indefinitely

Re: Is this a concurrency bug in base?

2011-10-14 Thread Simon Marlow
On 12/10/2011 12:24, Bertram Felgenhauer wrote: Jean-Marie Gaillourdet wrote: This is my previous program with your workaround, it is also attached as TypeRepEqLock.hs [snip] Compile and execute: $ ghc-7.0.3 -threaded -rtsopts TypeRepEqLock.hs $ while true ; do ./TypeRepEqLock +RTS -N ; do

Re: Is this a concurrency bug in base?

2011-10-14 Thread Bertram Felgenhauer
Simon Marlow wrote: > >import Control.Concurrent > >import Control.Exception > >import Control.Monad > >import System.IO.Unsafe > > > >main :: IO () > >main = do > > -- evaluate lock -- adding this line fixes the problem > > > > fin1<- newEmptyMVar > > fin2<- newEmptyMVar > > > > fo