[GHC] #7773: Waiting on non-kqueue supported files on OS X

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Neither the old IO manager nor the new "parallel" IO manager properly handle waiting on files on Mac OS X when kqueue does not support the device type. PHO reported this on ghc-devs: http://www.haskell.org/pipermail/ghc-devs/2013-March/000798.html. Here is the gist of it: the IO manager uses kqueue to wait on files on OS X. kqueue does not support all files. For example, on older versions of OS X (10.5.8) it cannot wait on tty devices and on even on 10.8.2 it cannot wait on /dev/random. Both the old and parallel IO managers suffered from the problem, but the consequences were slightly different. With the old IO manager the situation was treated as the file being ready, which would just cause the waiting thread to run again. The parallel IO manager changed things slightly and now it just throws an exception and terminates the program. So the behavior when this happens in the parallel IO manager is not acceptable. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by AndreasVoellmy): I added a patch to make the parallel io manager work the same way as the old io manager; namely, when a file is registered with the a kqueue-based IO manager and kevent returns EINVAL, then the manager simply calls the callback provided by the user for the event. This is a first step to an improved handling of this situation. Next step would be to register the event and callback with a manager that can actually handle the file appropriately. As discussed in the email thread with PHO, it seems that select is best for this. So to finish this, we should: 1. Implement a select-based backend. 2. Have the TimerManager use the select-based backend and export file registration commands from TimerManager. 3. Have Thread handle the fallback to the TimerManager when the preferred IO manager fails. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by PHO): Thanks AndreasVoellmy for the patch, but please don't forget that the old MacOS X returns ENOTSUP instead of EINVAL :) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by AndreasVoellmy): Maybe this is version-specific. For example, when I run your test program on 10.8.2 with /dev/random, kqueue fails with errno set to 22, which is EINVAL. Any thoughts on how we can reliably detect this problem across versions? Should we check either EINVAL or ENOTSUP? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by PHO): Replying to [comment:4 AndreasVoellmy]:
Should we check either EINVAL or ENOTSUP?
Yes, I think so. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by AndreasVoellmy): It seems that the Foreign.C.Error module does not define eNOTSUP. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by PHO): Replying to [comment:6 AndreasVoellmy]:
It seems that the Foreign.C.Error module does not define eNOTSUP.
Indeed. Attached a patch to define it. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by AndreasVoellmy): Added a patch (cumulative - i.e. it has all the patches so far) that also checks on ENOTSUP. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ----------------------------------------+----------------------------------- Reporter: AndreasVoellmy | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Comment(by PHO): Replying to [comment:8 AndreasVoellmy]:
Added a patch (cumulative - i.e. it has all the patches so far) that also checks on ENOTSUP.
With the correction above, I confirmed your patch works fine. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ---------------------------------+------------------------------------------ Reporter: AndreasVoellmy | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: libraries/base | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Incorrect result at runtime Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * status: new => patch * difficulty: => Unknown -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ---------------------------------+------------------------------------------ Reporter: AndreasVoellmy | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.8.1 Component: libraries/base | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Incorrect result at runtime Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * milestone: => 7.8.1 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ---------------------------------+------------------------------------------ Reporter: AndreasVoellmy | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.8.1 Component: libraries/base | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Incorrect result at runtime Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by igloo): See also #7839 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ---------------------------------+------------------------------------------ Reporter: AndreasVoellmy | Owner: AndreasVoellmy Type: bug | Status: patch Priority: normal | Milestone: 7.8.1 Component: libraries/base | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Incorrect result at runtime Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by AndreasVoellmy): * owner: => AndreasVoellmy -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7773: Waiting on non-kqueue supported files on OS X ---------------------------------+------------------------------------------ Reporter: AndreasVoellmy | Owner: AndreasVoellmy Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: libraries/base | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Incorrect result at runtime Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by AndreasVoellmy): * status: patch => merge -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7773#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC