Missing error cases in GHC.Internal.IO.Windows.Handle
In GHC.Internal.IO.Windows.Handle I see:
hwndReadNonBlocking hwnd ptr offset bytes
= do mngr <- Mgr.getSystemManager
val <- withOverlappedEx mngr "hwndReadNonBlocking" (toHANDLE hwnd)
(isAsynchronous hwnd) offset (startCB ptr)
completionCB
return $ ioValue val
where ioValue
is a record selector:
data IOResult a
= IOSuccess { ioValue :: a }
| IOFailed { ioErrCode :: Maybe Int }
So what happens if val
is IOFailed
? Just a runtime crash.
The same thing happens in hwndWriteNonBlocking
. Another runtime crash.
This seems outright wrong. So far as I can see IOFailed
is a real possibility.
As part of !13308 (closed) I am expunging incomplete record selectors, which is what brought this up. I have adjusted the code so that, while it still crashes, it gives a more localised error message, and includes the error code. But it needs fixing properly by someone who understands what is going on.