
On Sun, Oct 20, 2024 at 01:06:01PM +0100, Tom Ellis wrote:
From my experiements with a small program (below) I conclude that the default handler is installed on every thread, and real_handler is installed *on the main thread only* *below* the default handler, so that if an `ExitCode` exception is thrown the default handler never gets a chance to see it.
Oh, I see that the uncaught exception handler is called in `reportError`, itself used by `real_handler`, thence `child_handler`, and `forkIO`. https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src//GHC.Inte... It's also used by the `real_handler` in TopHandler.hs, and thence `topHandler` and `runIO`. https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src/GHC.Inter... So the uncaught exception handler is not really "installed", it's just used by the handlers installed by `forkIO` and `runMainIO` (the latter wraps main, as per the documentation). So I think I probably understand what's going on now. Tom