GHC | 27 May 12:08 2012

#6126: Fix risk of dead-lock in documentation of Control.Concurrent

#6126: Fix risk of dead-lock in documentation of Control.Concurrent
-------------------------------+--------------------------------------------
 Reporter:  basvandijk         |          Owner:                  
     Type:  bug                |         Status:  new             
 Priority:  normal             |      Component:  libraries/base  
  Version:  7.4.1              |       Keywords:                  
       Os:  Unknown/Multiple   |   Architecture:  Unknown/Multiple
  Failure:  Documentation bug  |       Testcase:                  
Blockedby:                     |       Blocking:                  
  Related:                     |  
-------------------------------+--------------------------------------------
 The [http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html
 /Control-Concurrent.html#g:12 current] documentation of
 `Control.Concurrent` proposes a function to wait for a child thread to
 complete:

 {{{
    myForkIO :: IO () -> IO (MVar ())
    myForkIO io = do
      mvar <- newEmptyMVar
      forkIO (io `finally` putMVar mvar ())
      return mvar
 }}}

 This function has the risk of causing a dead-lock. If an asynchronous
 exception if thrown before the `putMVar` exception handler is installed
 the `mvar` will remain empty. This causes a dead-lock when the `mvar` is
 taken.

 The attached patch fixes this problem by correctly masking asynchronous
(Continue reading)

GHC | 5 Jun 10:43 2012

Re: #6126: Fix risk of dead-lock in documentation of Control.Concurrent

#6126: Fix risk of dead-lock in documentation of Control.Concurrent
---------------------------------+------------------------------------------
    Reporter:  basvandijk        |       Owner:                   
        Type:  bug               |      Status:  new              
    Priority:  normal            |   Milestone:                   
   Component:  libraries/base    |     Version:  7.4.1            
    Keywords:                    |          Os:  Unknown/Multiple 
Architecture:  Unknown/Multiple  |     Failure:  Documentation bug
  Difficulty:  Unknown           |    Testcase:                   
   Blockedby:                    |    Blocking:                   
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonmar):

  * difficulty:  => Unknown

Comment:

 I've actually been intending to fix this a different way.  I want to add
 `forkFinally`:

 {{{
 forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
 forkFinally action action =
   mask $ \restore ->
     forkIO $ try (restore action) >>= action
 }}}

 Furthermore I'd like to add an Async API that builds on this to add some
 higher level concurrency operators, but I'll post a proposal on the
(Continue reading)

GHC | 5 Jun 15:59 2012

Re: #6126: Fix risk of dead-lock in documentation of Control.Concurrent

#6126: Fix risk of dead-lock in documentation of Control.Concurrent
---------------------------------+------------------------------------------
    Reporter:  basvandijk        |       Owner:                   
        Type:  bug               |      Status:  new              
    Priority:  normal            |   Milestone:                   
   Component:  libraries/base    |     Version:  7.4.1            
    Keywords:                    |          Os:  Unknown/Multiple 
Architecture:  Unknown/Multiple  |     Failure:  Documentation bug
  Difficulty:  Unknown           |    Testcase:                   
   Blockedby:                    |    Blocking:                   
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by basvandijk):

 I'm looking forward to it. The functions in my
 [http://hackage.haskell.org/packages/archive/threads/0.5/doc/html/Control-
 Concurrent-Thread.html threads] package can also benefit from this. Or
 maybe the package will be deprecated in favor of your new Async API.

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6126#comment:2>
GHC | 11 Jun 16:38 2012

Re: #6126: Fix risk of dead-lock in documentation of Control.Concurrent

#6126: Fix risk of dead-lock in documentation of Control.Concurrent
--------------------------------+-------------------------------------------
  Reporter:  basvandijk         |          Owner:                  
      Type:  bug                |         Status:  closed          
  Priority:  normal             |      Milestone:                  
 Component:  libraries/base     |        Version:  7.4.1           
Resolution:  fixed              |       Keywords:                  
        Os:  Unknown/Multiple   |   Architecture:  Unknown/Multiple
   Failure:  Documentation bug  |     Difficulty:  Unknown         
  Testcase:                     |      Blockedby:                  
  Blocking:                     |        Related:                  
--------------------------------+-------------------------------------------
Changes (by simonmar):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 Fixed:

 {{{
 commit 40d1be115d2a5a409e9b747c347cd909a9607c42
 Author: Simon Marlow <marlowsd <at> gmail.com>
 Date:   Thu Jun 7 16:10:47 2012 +0100

     add forkFinally

     This is a more robust version of "forkIO (m `finally` k)", because it
     closes a window between thread creation and the finally where the
(Continue reading)


Gmane