[GHC] #3815: System.Win32.Types.failWith segfaults on unknown error
code
GHC
trac at galois.com
Sun Jan 10 22:57:00 EST 2010
#3815: System.Win32.Types.failWith segfaults on unknown error code
----------------------------------+-----------------------------------------
Reporter: dherington | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries (other) | Version: 6.10.1
Keywords: getErrorMessage | Difficulty: Easy (less than 1 hour)
Os: Windows | Testcase:
Architecture: Unknown/Multiple | Failure: Runtime crash
----------------------------------+-----------------------------------------
If a (Windows) system call returns an error code not known to
FormatMessage, System.Win32.Types.failWith segfaults. failWith
incorrectly assumes that getErrorMessage never returns a NULL pointer.
A simple fix in failWith is to replace:
msg <- peekTString c_msg
-- We ignore failure of freeing c_msg, given we're already failing
_ <- localFree c_msg
by:
msg <- if c_msg == nullPtr
then return $ "Error 0x" ++ Numeric.showHex err_code ""
else do msg <- peekTString c_msg
-- We ignore failure of freeing c_msg, given we're
already failing
_ <- localFree c_msg
return msg
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3815>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list