[GHC] #11575: Program crashes only when compiled via LLVM

GHC ghc-devs at haskell.org
Sun Feb 14 03:47:12 UTC 2016


#11575: Program crashes only when compiled via LLVM
--------------------------------------+----------------------------------
           Reporter:  Guest00000      |             Owner:
               Type:  bug             |            Status:  new
           Priority:  normal          |         Milestone:
          Component:  None            |           Version:  7.10.3
           Keywords:  llvm            |  Operating System:  Windows
       Architecture:  x86_64 (amd64)  |   Type of failure:  Runtime crash
          Test Case:                  |        Blocked By:
           Blocking:                  |   Related Tickets:
Differential Rev(s):                  |         Wiki Page:
--------------------------------------+----------------------------------
 `llvm-test.hs`:
 {{{#!hs
 import System.IO
 import Foreign.Storable
 import Foreign.Marshal.Alloc
 import Data.Word

 main = do
     hSetBuffering stdout NoBuffering

     test 1000
     test 5000
   where
     test n = do
         allocaBytes (n * 4) $ \p -> do
             sequence_ [
               pokeByteOff p (i * 4) (0x12345678 :: Word32)
               | i <- [ 0 .. n - 1 ]
               ]
         putStrLn $ show n ++ " fine"

 }}}
 ----
 Cygwin shell:
 {{{
 user at pc ~
 $ ghc llvm-test.hs && ./llvm-test.exe
 [1 of 1] Compiling Main             ( llvm-test.hs, llvm-test.o )
 Linking llvm-test.exe ...
 1000 fine
 5000 fine

 user at pc ~
 $ touch llvm-test.hs

 user at pc ~
 $ ghc llvm-test.hs -fllvm && ./llvm-test.exe
 [1 of 1] Compiling Main             ( llvm-test.hs, llvm-test.o )
 Linking llvm-test.exe ...
 1000 fine
 Segmentation fault

 }}}
 ----
 {{{
 <erikd> `Guest00000: try adding -O2 to the compiler command line.
 <`Guest00000> erikd: it now segfaults even before printing "1000 fine"
 <`Guest00000> wait, one time it printed one character "1" before crashing
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11575>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list