#4514: System.Timeout cannot properly cancel IO actions with new IO manager
---------------------------------+------------------------------------------
    Reporter:  adept             |       Owner:  tibbe                      
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  Runtime System             
     Version:  7.0.1             |    Keywords:                             
    Testcase:                    |   Blockedby:                             
          Os:  Unknown/Multiple  |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------

Comment(by adept):

 Ok.

 After chat with tibbe it seems like the root cause lies here:

 {{{
 registerFd_ :: EventManager -> IOCallback -> Fd -> Event
             -> IO (FdKey, Bool)
 registerFd_ EventManager{..} cb fd evs = do
   u <- newUnique emUniqueSource
   modifyMVar emFds $ \oldMap -> do
     let fd'  = fromIntegral fd
         reg  = FdKey fd u
         !fdd = FdData reg evs cb
         (!newMap, (oldEvs, newEvs)) =
             case IM.insertWith (++) fd' [fdd] oldMap of
               (Nothing,   n) -> (n, (mempty, evs))
               (Just prev, n) -> (n, pairEvents prev newMap fd')
         modify = oldEvs /= newEvs
     when modify $ I.modifyFd emBackend fd oldEvs newEvs
     return (newMap, (reg, modify))
 }}}

 After reconnect, when `recv` is called, it checks for data with C `recv`
 and (since there is nothing there yet) calls `threadWaitRead` on the
 approprate descriptor. This in turn should call `registerFd`.

 Since there is handler for the same FD in `emFds` already, `pairEvent`
 would try to compute the combined event mask. In this case `oldEvs ==
 newEvs`, so `I.modifyFd` would not be called, and this must be the source
 of the problem.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4514#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to