Skip to content

ghc-8.0.2_rc1 inlines string literals too aggressively, breaks tests of http-client-0.4.30

GHC version 8.0.1.20161117

-- $ cat BodySpec.hs 
-- $ ghc --make -O1 -package={base,bytestring} BodySpec.hs -o a && ./a
{- # OPTIONS_GHC -Wall -Werror #-}
module Main (main) where

import qualified Data.ByteString as S
import qualified Data.ByteString.Char8 as S8

main :: IO ()
main = (S8.concat (map S.singleton (S.unpack (S8.pack "<foo>"))) == S8.empty) `seq` return ()
$ ghc --make -O1 -package={base,bytestring} BodySpec.hs -o a && ./a
Segmentation fault (core dumped)

The cause is similar to #12757 (closed): low-level optimisations inline string literal (or it's wrapping value? i don't know) in multiple places. That breaks pointer-chasing in bytestring package.

$ strings a | fgrep '<foo>'
<foo>
<foo>
<foo>
<foo>
Edited by Sergei Trofimovich
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information