[GHC] #14361: GHC HEAD miscompiles `text-containers`

GHC ghc-devs at haskell.org
Tue Oct 17 10:45:27 UTC 2017


#14361: GHC HEAD miscompiles `text-containers`
-------------------------------------+-------------------------------------
        Reporter:  hvr               |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by hvr:

Old description:

> When compiling and running `text-containers`'s test-suite, the test-cases
> involving lookup functions (e.g. `member :: Key -> TextSet -> Bool`) fail
> indeterministically.
>
> ''more details to follow''

New description:

 When compiling and running `text-containers`'s test-suite, the test-cases
 involving lookup functions (e.g. `member :: Key -> TextSet -> Bool`) fail
 indeterministically.

 NB: The code in question works perfectly for GHC 7.10.3/8.0.2/8.2.1; and
 I've also verified this isn't related to the new `compareByteArray#`
 primop; in fact you get the very same failures if you force `text-
 containers` to use the memcmp FFI (by editing the respective `if`
 conditional in the .cabal file).

 Repro instructions (sorry, haven't had time to minimize it yet):

 {{{#!sh
 # get wip/ghc-T14361 branch of `text-containers`

 git clone https://github.com/hvr/text-containers.git -b wip/ghc-T14361

 cd text-containers/

 # generate cabal.project.local

 cat > cabal.project.local <<EOF

 repository head.hackage
    url: http://head.hackage.haskell.org/
    secure: True
    root-keys:
 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740
 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb
 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e
    key-threshold: 3

 allow-newer: *:base, tagged-0.8.5:template-haskell

 EOF


 # update head.hackage package index if needed;
 # use
 https://github.com/hvr/head.hackage/blob/master/scripts/head.hackage.sh
 script

 head.hackage.sh update
 }}}


 You can now build & run the test-suite via (if you need, you can replace
 `ghc-8.3.20171016` by the full path to your `inplace/bin/ghc-stage2`
 executable):

 {{{
 cabal new-test -w ghc-8.3.20171016
 }}}

 ...and this will report

 {{{
 ...
 All 44 tests passed (3.81s)
 Test suite text-containers: PASS
 Test suite logged to:
 dist-newstyle/build/x86_64-linux/ghc-8.3.20171016/text-
 containers-0.1.0.0/t/text-containers/test/text-containers-0.1.0.0-text-
 containers.log
 1 of 1 test suites (1 of 1 test cases) passed.
 }}}

 If however, you edit `src/Internal2.hs` and disable either the

  - `{-# OPTIONS_GHC -fno-strictness #-}` or the
  - `{-# NOINLINE cmpBA2OfsLen #-}`

 pragmas, and re-run the test-suite, those 6 of the 44 tests which test the
 `member`/`lookup{GE,LE}` operations will start failing, e.g.

 {{{
 ...
     null:             OK (0.06s)
       +++ OK, passed 100 tests.
     member:           FAIL
       *** Failed! Falsifiable (after 25 tests and 6 shrinks):
       Ps
 [("\74914\869082\952045\187526\US",18),("\444739R^\DC3\RSpr",-20),("Je\5900LfM\SI\622028\13867\861002\\+?\49284Mi",9),("\ETB",-3),("\EOT,3/{wdirM\66595\829945R\17707_9\1079715DA\SOH5",0),("Md",-13),("gSY\ESC3N\DLEE\864876'~\184683z\ESCy<\r\448917\787640\SYN\752866",15)]
       Use --quickcheck-replay=592157 to reproduce.
     (!?):             FAIL
       *** Failed! Falsifiable (after 18 tests and 2 shrinks):
       Ps
 [("\DC3|X|\488551)|8\NAKa\278082an\649221\v\843318",1),("\603109\SYN\EOT\999535<M%\USBXEu\734582",0),("C\625018.",-7),("iV\ESCu",-16),("d\aJ7@\DLE2\102734\a\868938",8),("i\974801rl\1094305b[\ESC\a?",-5),("\95327[hB",1),("rG\v\1017578\CAN\ACK",-6)]
       Use --quickcheck-replay=713273 to reproduce.
   TextSet
     toList.fromList:  OK (0.07s)
       +++ OK, passed 100 tests.
 ...
 6 out of 44 tests failed (3.20s)
 Test suite text-containers: FAIL
 Test suite logged to:
 dist-newstyle/build/x86_64-linux/ghc-8.3.20171016/text-
 containers-0.1.0.0/t/text-containers/test/text-containers-0.1.0.0-text-
 containers.log
 0 of 1 test suites (0 of 1 test cases) passed.
 cabal: Tests failed for test:text-containers from text-containers-0.1.0.0.

 }}}


 And you'll notice that even if `--quickcheck-replay` is used, the failures
 will not be 100% deterministic.

--

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


More information about the ghc-tickets mailing list