`unsafeDecodeUtf8` does not correct propagate asynchronous exceptions
I imagine this is very hard to reproduce but I killed a process using Ctrl-C
and for the following incorrect error.
[nix-shell:~/ghc-splice-imports/gen-test]$ ~/ghc-splice-imports/_ipe/stage1/bin/ghc MultiLayerModules.hs -fno-code -v1 +RTS -hT -RTS
Starting ghc-debug on socket: /home/matt/.local/share/ghc-debug/debuggee/sockets/2755935-ghc
^Cghc: panic! (the 'impossible' happened)
GHC version 9.13.20241010:
Failed to decodeUtf ""./DummyLevel5M003.dyn_o"", because: Cannot decode input: user interrupt
Package: ghc-internal
Module: GHC.Internal.IO.Exception
Type: SomeAsyncException
CallStack (from HasCallStack):
panic, called at compiler/GHC/Data/OsPath.hs:29:19 in ghc-9.13-inplace:GHC.Data.OsPath
unsafeDecodeUtf, called at compiler/GHC/Unit/Module/Location.hs:160:33 in ghc-9.13-inplace:GHC.Unit.Module.Location
It seems that decodeUtf
does not propagate async exceptions properly, and hence unsafeDecodeUtf8
turns an async exception into a synchronous exception which leaks to be displayed to the user. Therefore the correct fix is probably to not catch async exceptions.
https://github.com/haskell/os-string/blob/master/System/OsString/Common.hs#L343