[GHC] #7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD)

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) --------------------------------+------------------------------------------- Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Component: Build System Version: 7.7 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Building GHC failed | Blockedby: Blocking: | Related: --------------------------------+------------------------------------------- Building GHC with parallel IO manager on Mac freezes when compiling the dph libraries in the phase 2. * This happens only if we specify "-j" to "make". Note that "make" closes stdin of sub-processes if "-j" is specified. * Even if we specify "-j" to "make", the problem disappears with stdout/stderr redirection. That is, "make -jN >& LOG &" works. * The "-d" option of "make" does not make any effects. * Programs compiled with built GHC (with our patches) work well. For test, I compiled a daemon HTTP server which closes stdin/stdout/stderr. It worked well. An IO manager is polling a kqueue fd. Another Haskell thread on another native thread registers an event through the same kqueue fd. In many cases, this works on Mac. In a certain situation, MacOS does not deliver an event to the IO manager. If the IO manager gets up and polls the kqueue fd, the event is delivered. This bug only appears when building GHC on Mac. I cannot find a simple way to reproduce it. Even if we find a way to reproduce it, I guess that we will probably reach a conclusion that this is a bug of kqueue of Mac. I have some evidences that kqueue of Mac is buggy: * http://comments.gmane.org/gmane.comp.lib.ev/1871 * http://lists.apple.com/archives/darwin-dev/2011/Jun/msg00016.html -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonmar): * difficulty: => Unknown Old description:
Building GHC with parallel IO manager on Mac freezes when compiling the dph libraries in the phase 2.
* This happens only if we specify "-j" to "make". Note that "make" closes stdin of sub-processes if "-j" is specified.
* Even if we specify "-j" to "make", the problem disappears with stdout/stderr redirection. That is, "make -jN >& LOG &" works.
* The "-d" option of "make" does not make any effects.
* Programs compiled with built GHC (with our patches) work well. For test, I compiled a daemon HTTP server which closes stdin/stdout/stderr. It worked well.
An IO manager is polling a kqueue fd. Another Haskell thread on another native thread registers an event through the same kqueue fd. In many cases, this works on Mac. In a certain situation, MacOS does not deliver an event to the IO manager. If the IO manager gets up and polls the kqueue fd, the event is delivered.
This bug only appears when building GHC on Mac. I cannot find a simple way to reproduce it. Even if we find a way to reproduce it, I guess that we will probably reach a conclusion that this is a bug of kqueue of Mac.
I have some evidences that kqueue of Mac is buggy:
* http://comments.gmane.org/gmane.comp.lib.ev/1871 * http://lists.apple.com/archives/darwin-dev/2011/Jun/msg00016.html
New description: Building GHC with parallel IO manager on Mac freezes when compiling the dph libraries in the phase 2. We '''suspect this is due to a bug in the OS X implementation of kqueue''', for the reasons given below. In the meantime, we have added an extra IO manager wakeup that appears to work around the problem; see `GHC/Event/Manager.hs`. Details: * This happens only if we specify "-j" to "make". Note that "make" closes stdin of sub-processes if "-j" is specified. * Even if we specify "-j" to "make", the problem disappears with stdout/stderr redirection. That is, "make -jN >& LOG &" works. * The "-d" option of "make" does not make any effects. * Programs compiled with built GHC (with our patches) work well. For test, I compiled a daemon HTTP server which closes stdin/stdout/stderr. It worked well. An IO manager is polling a kqueue fd. Another Haskell thread on another native thread registers an event through the same kqueue fd. In many cases, this works on Mac. In a certain situation, MacOS does not deliver an event to the IO manager. If the IO manager gets up and polls the kqueue fd, the event is delivered. This bug only appears when building GHC on Mac. I cannot find a simple way to reproduce it. Even if we find a way to reproduce it, I guess that we will probably reach a conclusion that this is a bug of kqueue of Mac. I have some evidences that kqueue of Mac is buggy: * http://comments.gmane.org/gmane.comp.lib.ev/1871 * http://lists.apple.com/archives/darwin-dev/2011/Jun/msg00016.html -- Comment: Added a bit of formatting and text to the description. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kazu-yamamoto): Andreas wrote C programs to simulate the parallel IO manager: https://github.com/AndreasVoellmy/epollbug kqueueserver2 uses kevent64() while kqueueserver3 uses kevent(). kqueue2 disclosed that kevent64() is unstable. The details are described in: https://discussions.apple.com/thread/4783301 We stopped using kevent64() and started using kevent() in the parallel IO manager. But building GHC still freezes. So, workaround is still necessary on Mac. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by AndreasVoellmy): * cc: andreas.voellmy@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kazu-yamamoto): Two pages which Andreas found: * http://lists.apple.com/archives/darwin- development/2004/Apr/msg00001.html * http://bugs.python.org/issue7401 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by AndreasVoellmy): It turns out that kqueueserver2.c (mentioned in previous comments in this item) had an error in it. Therefore, it does not indicate any problem with kevent64. The problem in that code occurred because the program allocated a struct kevent64_s and failed to initialize some of that struct's fields. There must have been some garbage values in these fields that caused kevent64 to behave oddly. The fix is to use the EV_SET64 macro to initialize the struct. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by igloo): What's the status of this ticket? Is the problem now understood, and the fix known? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kazu-yamamoto): GHC head has already workaround for this. Please see libraries/base/GHC/Event/Manager.hs. You can find "#if defined(darwin_HOST_OS)". But we still have two problems: - Building GHC on Mac sometime fails. We need to understand whether or not this is due to the new IO manager. Unfortunately, I cannot "make install" GHC head at this moment as I described in ghc-deps. - We need to rescue old MacOS. http://www.haskell.org/pipermail/ghc- devs/2013-March/000798.html -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7651: Buiding GHC with parallel IO manager freezes on Mac (not on FreeBSD) ---------------------------------+------------------------------------------ Reporter: kazu-yamamoto | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.1 Component: Build System | Version: 7.7 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: Building GHC failed Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * priority: normal => high * milestone: => 7.8.1 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7651#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC