#2558: re-throwing an asynchronous exception throws it synchronously
---------------------------------+------------------------------------------
    Reporter:  simonmar          |        Owner:  simonmar        
        Type:  bug               |       Status:  new             
    Priority:  normal            |    Milestone:  6.12 branch     
   Component:  Compiler          |      Version:  6.8.3           
    Severity:  normal            |   Resolution:                  
    Keywords:                    |   Difficulty:  Unknown         
    Testcase:                    |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |  
---------------------------------+------------------------------------------
Comment (by int-e):

 My first instinct would be to pass a flag to exception handlers (changing
 the type of the {{{catch#}}} primitive, and the stack frame creation in
 {{{RaiseAsync.c}}} and {{{Exception.cmm}}} accordingly) to sort out at
 their leisure. Igloo's idea is similar in that would also pass a flag
 along with the exception, although the flag is set at a different point.
 I'm not sure which is easier to accomplish.

 It's already possible to use such a flag:
 {{{
 throwAsync :: Exception e => e -> IO ()
 throwAsync e = do
     target <- myThreadId
     throwTo target e

 throwSyncOrAsync :: Exception e => Bool -> e -> IO ()
 throwSyncOrAsync async = if async then throwAsync else throwIO
 }}}

 If such a flag is added, I'd also like to have a variant of {{{catch}}}
 that gets to see it in {{{Control.Exception}}}, say,
 {{{
 catchSyncOrAsync :: Exception e => IO a -> (Bool -> e -> IO a) -> IO a
 }}}
 and possibly {{{catchSync}}} and {{{catchAsync}}}.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2558#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to