Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#12855 closed bug (duplicate)

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

Reported by: slyfox Owned by:
Priority: normal Milestone: 8.0.2
Component: Compiler Version: 8.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #12757 Differential Rev(s):
Wiki Page:

Description (last modified by slyfox)

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: 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>

Change History (6)

comment:1 Changed 2 years ago by slyfox

Description: modified (diff)

comment:2 Changed 2 years ago by bgamari

Resolution: duplicate
Status: newclosed

This is another case of #12757. Unfortunately, it seems that the fix for #11158 wasn't present in the 8.0.2-rc1 release due to a silly mistake on my part. I've confirmed that merging the patch for #11158 to ghc-8.0 resolves this crash.

comment:3 Changed 2 years ago by bgamari

Thanks for the reduced testcase, slyfox! This will be a great addition to the testsuite.

comment:4 Changed 2 years ago by slyfox

I'm a bit lost here. Can you clarify which commit in ghc-8.0 branch should fix it? I will apply it locally to -rc1 and try to rebuild ghc.

comment:6 Changed 2 years ago by Ben Gamari <ben@…>

In 5bce207/ghc:

testsuite: Add test for #12855

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2731

GHC Trac Issues: #12855
Note: See TracTickets for help on using tickets.