#4514: IO manager can deadlock if a file descriptor is closed behind its back
------------------------------------------+---------------------------------
Reporter: adept | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.0.2
Component: Runtime System | Version: 7.0.1
Resolution: | Keywords:
Testcase: | Blockedby:
Difficulty: | Os: Linux
Blocking: | Architecture: Unknown/Multiple
Failure: Incorrect result at runtime |
------------------------------------------+---------------------------------
Comment(by bos):
Goddamn Trac. Augh.
* The fdWasClosed function that we added during 6.13 development was
subject to a race condition: you could mark an fd as closed after another
thread had performed an open or similar that could reuse that fd.
* The new closeFd function is necessary to close that race. It manages
this by closing the fd while holding an MVar, so another thread can't race
in and register the fd.
* Why does closeFd accept an action as parameter? Because under Windows,
you have to use different functions to close a file descriptor depending
on whether it's owned by Winsock or the rest of win32.
* If the name should be something like closeFdWith to be more descriptive,
that's fine (please let me know if you have a preference), as my purpose
is to close the race :-)
* Why should closeFdWith be exported from Control.Concurrent? Because
threadWaitRead and threadWaitWrite already are, and closeFdWith must be
used with those functions now to guarantee race-free closing.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4514#comment:33>
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