Skip to content

GHC 8.11.0.20200527 + bytestring PR191 compile time blowup

Summary

GHC master in apparent infinite loop compiling concatenation of literal bytestrings with bytestring PR191 (merged in my ghc-cpu-blowup branch of bytestring on github)

Steps to reproduce

Build the attached test program (per the attached cabal file) against bytestring with PR191 foo.hs foo.cabal cabal.project

Expected behavior

Not loop at 100% CPU, seemingly "forever"

Environment

  • GHC version used: 8.11.0.20200527 + patched bytestring

Optional:

  • Operating System: FreeBSD 12.0
  • System Architecture: x86_64

Some detail

The problem code is inside the #if !defined(NOBUG) block of:

main :: IO ()
main = do
    C8.putStrLn
        $ "beef81a00001000200000003076578616d706c6503636f6d00000f0001c00c000f00010000012c"
       <> "0008000a036d7831c00cc00c000f00010000012c0008000a036d7832c00c00002904d000000000"
       <> "0000c02b000100010000012c0004c0000201c03f000100010000012c0004c0000202"
#if !defined(NOBUG)
    C8.putStrLn
        $ "beef81a0"         -- 0. header
       <> "00010002"         -- 4. qdcount, ancount
       <> "00000003"         -- 8. nscount, arcount
       <> "076578616d706c65" -- 12. "example."
       <> "03636f6d00"       -- 20. "com."
       <> "000f0001"         -- 25. MX IN
       <> "c00c"             -- 29. "example.com" compressed
       <> "000f0001"         -- 31. MX IN
       <> "0000012c"         -- 35. TTL = 300
       <> "0008"             -- 39. RDLEN = 8
       <> "000a"             -- 41. pref = 10
       <> "036d7831c00c"     -- 43. exch = "mx1.example.com" compressed
       <> "c00c"             -- 49. "example.com" compressed
       <> "000f0001"         -- 51. MX IN
       <> "0000012c"         -- 55. TTL = 300
       <> "0008"             -- 59. RDLEN = 8
       <> "000a"             -- 61. pref = 10
       <> "036d7832c00c"     -- 63. exch = "mx2.example.com" compressed
       <> "000029"           -- 69. . OPT
       <> "04d0"             -- 72. buffer size 1232
       <> "0000"             -- 74. extRCODE=0 ednsVERSION=0
       <> "00000000"         -- 76. Flags=0x0000, RDLEN=0
       <> "c02b"             -- 80. "mx1.example.com" compressed
       <> "00010001"         -- 82. A IN
       <> "0000012c"         -- 86. TTL = 300
       <> "0004"             -- 90. RDLEN = 4
       <> "c0000201"         -- 92. 192.0.2.1
       <> "c03f"             -- 96. "mx2.example.com" compressed
       <> "00010001"         -- 98. A IN
       <> "0000012c"         -- 102. TTL = 300
       <> "0004"             -- 106. RDLEN = 4
       <> "c0000202"         -- 108. 192.0.2.2
#endif

which does not compile in under an hour, possibly heat-death of the universe, hard to know... The same string without <> (for readability) compiles just fine.

Edited by vdukhovni
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information