Skip to content

GHCi panic: "Loading temp shared object failed" when adding a new module

Files:

-- Bug.hs
module Bug where
import Bug2
bug = bug2

-- Bug2.hs
module Bug2 where
bug2 = ()

Steps to reproduce:

  1. Create the files as above
  2. Start GHCi:
$ ghc-8.2.0.20170704 --interactive -fobject-code
λ> :load Bug
Ok, 2 modules loaded.
  1. Without exiting GHCi, add a new file:
-- NewModule.hs
module NewModule where
newFn = ()

and change Bug2.hs to:

module Bug2 where
import NewModule
bug2 = newFn

to introduce a transitive dependency Bug -> Bug2 -> NewModule.

  1. In GHCi
λ> :reload
[2 of 3] Compiling Bug2             ( Bug2.hs, Bug2.o )
Ok, 3 modules loaded.
λ> bug
ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.0.20170704 for x86_64-unknown-linux):
        Loading temp shared object failed: /tmp/ghc22212_0/libghc_4.so: undefined symbol: NewModule_newFn_closure

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

The problem also exists without -fobject-code. The error message is different:

λ> bug
ghc: ^^ Could not load 'NewModule_newFn_closure', dependency unresolved. See top entry above.


ByteCodeLink.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
  NewModule_newFn_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org

Also affects GHC 8.0.2 and 7.10.

Trac metadata
Trac field Value
Version 8.2.1-rc3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information