[GHC] #13167: GC and weak reference finalizers and exceptions
GHC
ghc-devs at haskell.org
Mon May 14 07:47:38 UTC 2018
#13167: GC and weak reference finalizers and exceptions
-------------------------------------+-------------------------------------
Reporter: Yuras | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by Phyx-):
* cc: Phyx- (added)
Comment:
Replying to [comment:2 simonmar]:
> Yes, this is technically a bug. We could have `runFinalizerBatch` catch
and discard exceptions (or print them to stdout; it's really a bug if a
finalizer throws an exception).
Any suggestions on how? the I/O manager seems to rely on using finalizers
to flush buffers, however for some reason my new I/O manager's finalizers
never get called. I assume because something else threw an exception.
I've modified `runFinalizerBatch` to handle exceptions (unless I
misunderstood the code)
{{{
runFinalizerBatch :: Int -> Array# (State# RealWorld -> State# RealWorld)
-> IO ()
runFinalizerBatch (I# n) arr =
let go m = IO $ \s ->
case m of
0# -> (# s, () #)
_ -> let !m' = m -# 1# in
case indexArray# arr m' of { (# io #) ->
case catch# (\p -> (# io p, () #)) (\_ s'' -> (#
s'', () #)) s of {
(# s', _ #) -> unIO (go m') s'
}}
in
go n
}}}
With `mio` the output varies between `..` and `....`, so not very
deterministic. with `winio` none of it ever runs...
Any ideas what else might be making these handlers not run at all? or how
I can debug this? for `winio` I can imagine one of the finalizers
deadlocking, an ffi call maybe. But the mio output is strange.
If we're going to rely on them for managing handles and buffers they would
ideally be a bit more robust...
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13167#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list