[GHC] #9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Runtime Blocked By: | crash Related Tickets: | Test Case: ghcirun004 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I was recently repeatedly running the validate test suite and got this test to fail: {{{ Actual stderr output differs from expected: --- /dev/null 2014-02-15 17:35:19.578872448 -0800 +++ ./ghci/should_run/ghcirun004.run.stderr 2014-10-24 14:46:15.289211100 -0700 @@ -0,0 +1 @@ +ghc: ioManagerWakeup: write: Bad file descriptor *** unexpected failure for ghcirun004(ghci) }}} Might be related to #5443. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm seeing this too, on Linux. Also on test T2589. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Does anyone have a clue what is going on here? I regularly get a batch of failures {{{ Unexpected failures: ffi/should_run ffi018_ghci [bad stdout or stderr] (ghci) ghci/should_run T2589 [bad stdout or stderr] (ghci) ghci/should_run ghcirun001 [bad stdout or stderr] (ghci) ghci/should_run ghcirun002 [bad exit code] (ghci) ghci/should_run ghcirun003 [bad stdout or stderr] (ghci) ghci/should_run ghcirun004 [bad stdout or stderr] (ghci) }}} all of which are this `ioManagerWakeup:write: Bad file descriptor` thing. What is `ioManagerWakeup`? Who calls it? Why? What does it mean to have a bad file descriptor? It's bad because I can't get a clean validate these days. Incidentally {{{ make TEST=ghcirun001 }}} works fine! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * priority: normal => highest * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by AndreasVoellmy): * cc: AndreasVoellmy (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): I haven't been able to recreate this on HEAD (a2e7bbfe7656cf7dbf1af4da5c077ac0b5d41127) on Ubuntu 14.04.1 LTS. Is there a test that fails most of the time? If so, how do you run it to get it to fail frequently? Or are these test failures occurring only rarely? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): For me they never occur when running the test on its own. They only occur during `sh validate --fast`. The difference, perhaps, is that many tests are running at the same time. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by thomie): Harbormaster just [https://phabricator.haskell.org/harbormaster/build/2075/ failed] on `ghcirun004` as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: crash | Related Tickets: Test Case: ghcirun004 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ezyang): I haven't seen this bug recently, but I don't see any commits which might have solved it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): I haven't seen it recently either. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * priority: highest => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * priority: highest => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by edsko): * cc: edsko (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: GHCi | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by edsko): Just FYI, I just saw this while using 7.10 to compile my project. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * cc: simonmar (added) * owner: => simonmar * component: GHCi => Runtime System Comment: I can reproduce the notorious 'ioManagerWakeup' bug. Not for `ghci004` itself, but for some other ghci tests. On my puny laptop with only 2 cores, I do the following: 1. Make sure the cpu is plenty busy, by running `ghc -e [0..] > /dev/null` in 3 different shells. 2. Run `make test EXTRA_HC_OPTS='+RTS -I0.1 -RTS' TEST='print002 print003 print006 print007 print008 print010'` For me, all tests always fail with: "ioManagerWakup: write: Bad file descriptor" Step 2 sets the 'GC idle time' for ghci script tests to 0.1 seconds (from the default for GHC/GHCi of 5 seconds, see #3408); the same value that is used for other tests with WAY=ghci (among which `ghci004`). The necessity of step 1 might explain why we don't see the bug when running a single test in isolation, but only when running validate, which runs a lot of tests at the same time. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Changes (by thomie): * status: new => patch * differential: => Phab:D714 Comment: I have a workaround patch which sets the 'GC idle time' for ghci tests to 0.3 seconds, which is the [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime- control.html#rts-options-gc default] for user programs. This prevents the bug from triggering. We can keep this ticket open until the real bug is fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by thomie): Smaller test case (without any cpu loading) for the real bug: {{{ $ cat T9722.hs main = return () $ ghc-7.10.0.20150307 -threaded -rtsopts T9722.hs $ ./T9722 +RTS -I0.000000001 T9722: ioManagerWakeup: write: Bad file descriptor }}} This only happens ~50% of the time, and it doesn't happen with 7.8.4. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): Where is T9722.hs? Is it in master branch somewhere? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): Replying to [comment:17 AndreasVoellmy]:
Where is T9722.hs? Is it in master branch somewhere?
Nevermind. I see the contents of T9722 from your message. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): I wasn't able to cause the problem with either T9722 with the arguments mentioned above or with the test with print002, etc. I tried with a fresh copy of ghc (version 7.11.20150307). I'll try to create it again with `sh validate --fast`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by thomie): Andreas: if your computer has more than 2 cores you might need to start more copies of `ghc -e [0..] > /dev/null`. Another good one to keep the cpu is busy is to compile `ghc` with `-j<ncores>` at the same time. Do all of that, and then run the `print002` test with `+RTS -I<some small number>`. It should work... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): I still haven't been able to recreate this. What OS are you running and can you post which commit of ghc you are working with? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by thomie): I am on 64 bit Ubuntu 14.04. I can reproduce with `ghc-7.10.0.20150307` and `ghc-7.11.20150307` from https://launchpad.net/~hvr/+archive/ubuntu/ghc (ghc-head). I have attached the output from running `./T9722 +RTS -I0.0001 -Ds`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): I'll keep trying to reproduce... in the meantime, can you try to recompile ghc with the following definition in rts/posix/Signals.c? Then recreate the bug and we will hopefully have a bit more info to help debug: {{{ void ioManagerWakeup (void) { int r; int fd; // Wake up the IO Manager thread by sending a byte down its pipe if (io_manager_wakeup_fd >= 0) { #if defined(HAVE_EVENTFD) StgWord64 n = (StgWord64)IO_MANAGER_WAKEUP; fd = io_manager_wakeup_fd; r = write(fd, (char *) &n, 8); #else StgWord8 byte = (StgWord8)IO_MANAGER_WAKEUP; fd = io_manager_wakeup_fd; r = write(fd, &byte, 1); #endif if (r == -1) { perror("ioManagerWakeup: write(A)"); sysErrorBelch("ioManagerWakeup: write; fd: %d", fd); } } } }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:23 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by thomie): I build a fresh ghc head (commit 8b7534b39052c9cb44411bea0ca311a751564d6c) with the change to `ioManagerWakeup` from comment:23. {{{ $ ~/ghc-master-build/inplace/bin/ghc-stage2 -threaded -rtsopts T9722.hs $ ./T9722 +RTS -I0.000000001 ioManagerWakeup: write(A): Bad file descriptor T9722: ioManagerWakeup: write; fd: 9: Bad file descriptor }}} I don't understand why the output is different when I redirect it to a file. But in case it gives you a clue, here it is: {{{ $ ./T9722 +RTS -I0.000000001 > T9722.stderr $ cat T9722.stderr ioManagerWakeup: write(A): Bad file descriptor T9722: ioManagerWakeup: write; fd: 9: Invalid argument }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:24 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): Thanks thomie! I think I see what is happening now: the TimerManager registers a file descriptor with the RTS for use by the `ioManagerWakeup()` function in `rts/posix/Signals.c`. When the TimerManager shuts down, it closes this file descriptor. I think there is a race condition where rts/Schedule.c calls `ioManagerWakeup()` after the TimerManager has shutdown. The TimerManager should only shutdown when the program is exiting, so it's probably safe to simply silently ignore the failing write, although this probably needs some review. In the meantime, I've modified `GHC/Event/Control.hs` to write `-1` to `io_manager_wakeup_fd` just before it closes the file descriptor. This should address the race condition. Can you compile your ghc with the attached Control.hs and check whether it makes the problem go away for you? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:25 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by thomie): I ran all the tests I mentioned before multiple times, and they all succeeded. Hurray! Before shipping: I did get a build warning about unused `UNPACK` in `W`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:26 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714 -------------------------------------+------------------------------------- Comment (by AndreasVoellmy): OK great! To summarize: Whenever the RTS has been inactive for idleGCDelayTime, the idle timer fires and calls `wakeUpRts()`, which in turn calls `ioManagerWakeup()`, which in turn writes a byte (or a few) to a file descriptor (stored in the `io_manager_wakeup_fd` variable) registered by the TimerManager and on which the TimerManager will wait. (Note that the write will only occur if the file descriptor is non-negative.) When the RTS shuts down, it shuts down the TimerManager, and in this process the file descriptor stored in `io_manager_wakeup_fd` is closed. In the error case, the idle timer fires after the close of the file occurs, and then the `write()` call in `ioManagerWakeup()` fails and the aforementioned error message gets printed. I think the solution in the Control.hs modification is solid; it addresses the problem without silently ignoring other error conditions due to the `write()`. Another solution might be to disable the idle timer once the program shutdown sequence has started, though that could have more far- reaching effects, so I think the minor Control.hs modification is good for now. I'll clean it up, add a comment or two, and then make a patch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:27 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file
descriptor
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: simonmar
Type: bug | Status: patch
Priority: high | Milestone: 7.10.1
Component: Runtime System | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime crash | Unknown/Multiple
Blocked By: | Test Case: ghcirun004
Related Tickets: | Blocking:
| Differential Revisions: Phab:D714
-------------------------------------+-------------------------------------
Comment (by Andreas Voellmy

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: merge Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714, | Phab:D722 -------------------------------------+------------------------------------- Changes (by AndreasVoellmy): * status: patch => merge * differential: Phab:D714 => Phab:D714, Phab:D722 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:29 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9722: ghcirun004 intermittently fails with ghc: ioManagerWakeup: write: Bad file descriptor -------------------------------------+------------------------------------- Reporter: ezyang | Owner: simonmar Type: bug | Status: closed Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: ghcirun004 Related Tickets: | Blocking: | Differential Revisions: Phab:D714, | Phab:D722 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged (via fb2ab1e3e04fde78d8970815f83b90d54359ae82), thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9722#comment:30 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC