[GHC] #1922: getChar + Ctrl-C on Windows in GHCi breaks

GHC trac at galois.com
Tue Dec 4 11:14:50 EST 2007


#1922: getChar + Ctrl-C on Windows in GHCi breaks
---------------------+------------------------------------------------------
 Reporter:  guest    |          Owner:  igloo  
     Type:  merge    |         Status:  new    
 Priority:  normal   |      Milestone:  6.8.3  
Component:  GHCi     |        Version:  6.8.1  
 Severity:  normal   |     Resolution:         
 Keywords:           |     Difficulty:  Unknown
 Testcase:           |   Architecture:  Unknown
       Os:  Windows  |  
---------------------+------------------------------------------------------
Changes (by simonmar):

  * owner:  simonmar => igloo
  * type:  bug => merge

Comment:

 Ok, several issues here.

 1) happens because when you hit `^C` in a console, Windows apprently
 causes a blocked `read()` on `stdin` to return 0, which the runtime
 interprets as EOF.  I haven't done anything about this yet, it seems
 fairly harmless.

 2) is the same as (1), just that the real `^C` exception gets delivered
 during the reporting of the EOF.

 3) happens due to a race condition in GHCi, which I've fixed.
 Interestingly, the fix required also fixing #1048 (make `forkIO` inherit
 `block` from the parent).

 4) happens due to another race condition, this time on the console
 handler, which is a global pointer to a `StablePtr`.  Under the right
 (wrong?) conditions, someone could free the `StablePtr` before it was
 dereferenced, leading to a crash.  I've fixed this.

 To merge, in GHC:

 {{{
 Tue Dec  4 03:09:47 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * forkIO starts the new thread blocked if the parent is blocked (#1048)

 Tue Dec  4 03:44:44 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * fix race conditions in sandboxIO (#1583, #1922, #1946)

 Tue Dec  4 07:39:18 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * protect console handler against concurrent access (#1922)
 }}}

 (note the first change needs documenting in the release notes, and I need

 in `libraries/base`:

 {{{
 Tue Dec  4 03:08:17 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * protect against concurrent access to the signal handlers (#1922)

 Tue Dec  4 07:39:40 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * protect console handler against concurrent access (#1922)
 }}}

 in `libraries/unix`:

 {{{
 Tue Dec  4 03:08:39 PST 2007  Simon Marlow <simonmar at microsoft.com>
   * protect against concurrent access to the signal handlers (#1922)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1922#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list