[GHC] #5902: Cannot tell from an exception handler whether the exception was asynchronous
GHC
ghc-devs at haskell.org
Fri Jul 19 10:19:15 CEST 2013
#5902: Cannot tell from an exception handler whether the exception was
asynchronous
-------------------------------------+------------------------------------
Reporter: simonmar | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by simonmar):
`newCatch` doesn't work for `bracket`. Consider:
{{{
bracket before after thing =
mask $ \restore -> do
a <- before
r <- restore (thing a) `onException` after a
_ <- after a
return r
}}}
Now, when the async exception is received, `onException` runs the
exception handler (`after a`), which cleans up whatever resource was
allocated by `before`. But when this this resumed after the async
exception, if `onException` is using `newCatch`/`newThrow`, it would re-
run `restore (thing a)`, which assumes that the resource is present and
accessible.
So while it might make sense to re-run the whole `unsafePerformIO` when we
resume after an async exception, it certainly doesn't make sense to do it
at a finer granularity. We don't want most exception-handlers to be
resumable.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5902#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list