Skip to content

"GHC.StgToCmm.Env: variable not found" (perhaps related to #17871)

Summary

Panic when compiling a module with -fno-enable-rewrite-rules (GHC 8.11.0.20200523)

 ghc: panic! (the 'impossible' happened)
  (GHC version 8.11.0.20200523:
        GHC.StgToCmm.Env: variable not found
  wild3_s1Hj
  local binds for:
  kilter_ipv4
  kilter2
  ipv1_s1Hb
  wild1_s1Hc
  wild2_s1Hd
  x1_s1He
  lwild1_s1Hf
  ipv6_s1Hi
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1221:37 in ghc:GHC.Utils.Outputable
        pprPanic, called at compiler/GHC/StgToCmm/Env.hs:152:9 in ghc:GHC.StgToCmm.Env

This is a stripped-down version of a failure to build the bytestring test-suite.

[ FWIW, the same example also triggers panics in GHC 8.6.5 and GHC 8.8.3 even without -fno-enable-rewrite-rules: #18228 (closed) ]

Steps to reproduce

ghc -O Lib -fno-enable-rewrite-rules with Lib.hs as below (also attached Lib.hs)

module Lib (kilter) where
import Data.ByteString.Internal

kilter :: ByteString -> IO ByteString
kilter ps@(PS x _ _) = createAndTrim 1 $ const $ pure 1

Expected behavior

No panic

Environment

  • GHC version used: 8.11.0.20200523

Optional:

  • Operating System: FreeBSD 12.0
  • System Architecture: x86_64
Edited by vdukhovni
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information