[GHC] #4906: peekCString crashes on handling nullPtr
GHC
cvs-ghc at haskell.org
Thu Jan 20 13:31:18 CET 2011
#4906: peekCString crashes on handling nullPtr
-------------------------------+--------------------------------------------
Reporter: sdjp | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (FFI)
Version: 6.12.3 | Keywords:
Testcase: | Blockedby:
Os: Linux | Blocking:
Architecture: x86_64 (amd64) | Failure: Runtime crash
-------------------------------+--------------------------------------------
Not quite sure what the 'correct' behaviour here is; but here's a minimal
test case:
{{{
-bash-3.2$ more TestCase.hs
import Foreign
import Foreign.C
main = do
str <- peekCString nullPtr
putStrLn str
-bash-3.2$ ghc --make TestCase.hs
-bash-3.2$ ./TestCase
Segmentation fault
}}}
I was not expecting a seg fault here. At minimum, peekCString
documentation should describe what is meant to happen when you pass it a
nullPtr (currently not mentioned at all). Better would be some form of
error reporting - I'm integrating with a C library, and it took me a while
to track down what the root cause of the seg fault was.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4906>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list