ghci crashes when I try to TAB-complete an import list
Steps to reproduce
I am typing "import Data.List (isS" and then press TAB
/opt/ghc/ghc-8.6.5/bin/ghciGHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for helpPrelude> import Data.List (isSghc: panic! (the 'impossible' happened) (GHC version 8.6.5 for x86_64-unknown-linux): ModOrigin: hidden module redefined
Expected behavior
suggest completions (or do nothing - as 8.6.4 does)
Environment
GHC version used: 8.6.5
Optional:
Operating System: GNU/Linux Fedora 30
System Architecture: x86_64
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
I am unable to reproduce this, using essentially the same system environment as you are (I'm on Ubuntu 18.04 instead of Fedora 30, but I doubt that is important).
Are you running GHCi in a particular directory by any chance? I tried to create a Data/List.hs file and run GHCi in the directory above that (so that if you tried to import Data.List, you'd get the usual attempting to use module ‘main:Data.List’ (./Data/List.hs) which is not loaded message), but I was still unable to observe the panic.
system:Linux Reaker 5.2.11-arch1-1-ARCH #1 SMP PREEMPT Thu Aug 29 08:09:36 UTC 2019 x86_64 GNU/Linux
archlinux use a dynamic linked ghc
System Architecture: x86_64
ghc-version: The Glorious Glasgow Haskell Compilation System, version 8.6.5
environment:
installed haskell-yesod and so on package by pacman.
cabal get zeromq4-haskell or just use it at deps
trigger: cabal v2-repl and put import System. then press Tab it crashed
it's pretty weird that cabal repl will not trigger the bug
ghc-pkg:
very-long warn (archlinux won't install haddock?i dont know),
The following packages are broken, either because they have a problemlisted above, or because they depend on a broken package.mongoDB-2.5.0.0tls-1.5.1conduit-extra-1.3.4conduit-1.3.1.1nonce-1.0.7resourcet-1.2.2bson-0.3.2.8streaming-commons-0.2.1.1yesod-1.6.0yesod-persistent-1.6.0.2yesod-form-1.6.6yesod-core-1.6.16yaml-0.11.1.2warp-3.3.0wai-extra-3.0.28persistent-2.10.1persistent-template-2.7.2monad-logger-0.3.30libyaml-0.1.1.0
the broken yesod? maybe because i tried to install yesod by cabal,but it failed,then i install it by pacman,and in ghci import Yesod does work,and so does the warp,wai etc (which is deps of yesod).
other broken package is installed and does work before i upgrade system package(and install yesod by pacman),maybe it's another story.
*Data.Data.Util> import Livghc: panic! (the 'impossible' happened) (GHC version 8.8.4 for x86_64-unknown-linux): ModOrigin: hidden module redefinedPlease report this as a GHC bug: https://www.haskell.org/ghc/reportabugLeaving GHCi.
I'm still unable to reproduce the bug, even with the instructions above. (I am using this commit, if that is relevant.) When I hit Tab, it simply autocompletes to import LiveCoding. What am I doing wrong?
One observation is that nix-shell gives me a different version of GHC that what you reported in #16996 (comment 302660):
$ ghc --versionThe Glorious Glasgow Haskell Compilation System, version 8.8.3
That's surprising. Is there a way to be absolutely certain that we're using the same GHC binary? (We should, given that we're both using a nix-shell with a pinned nixpkgs.)
What other files could possibly make a difference? I did cabal clean and can still reproduce. At some point I did gen-hie > hie.yaml or similar, maybe that makes a difference? (Although it only should have an effect for the Haskell Language Server, I believe.)
Are you using NixOS or another system? Even Linux? That might have an influence on the GHC binary.
(Thanks for pinning the commit hash, I forgot that.)
Just to make sure we're doing the exact same steps, here is what I tried:
$ git clone https://github.com/turion/essence-of-live-coding$ cd essence-of-live-coding/$ git reset --hard fd3c78ff795b8e1e0a9ac4b5104971dc4b466202$ nix-shell$ cd essence-of-live-coding$ cabal replBuild profile: -w ghc-8.8.4 -O1In order, the following will be built (use -v for more details): - essence-of-live-coding-0.2.4 (lib) (first run)Preprocessing library for essence-of-live-coding-0.2.4..GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help[ 1 of 38] Compiling LiveCoding.LiveProgram ( src/LiveCoding/LiveProgram.lhs, interpreted )[ 2 of 38] Compiling LiveCoding.Cell ( src/LiveCoding/Cell.lhs, interpreted )[ 3 of 38] Compiling LiveCoding.Debugger ( src/LiveCoding/Debugger.lhs, interpreted )[ 4 of 38] Compiling LiveCoding.Coalgebra ( src/LiveCoding/Coalgebra.lhs, interpreted )[ 5 of 38] Compiling LiveCoding.Cell.Monad ( src/LiveCoding/Cell/Monad.hs, interpreted )[ 6 of 38] Compiling LiveCoding.Cell.Resample ( src/LiveCoding/Cell/Resample.hs, interpreted )[ 7 of 38] Compiling LiveCoding.Cell.Monad.Trans ( src/LiveCoding/Cell/Monad/Trans.hs, interpreted )[ 8 of 38] Compiling LiveCoding.Exceptions.Finite ( src/LiveCoding/Exceptions/Finite.lhs, interpreted )[ 9 of 38] Compiling LiveCoding.Exceptions ( src/LiveCoding/Exceptions.lhs, interpreted )[10 of 38] Compiling LiveCoding.External ( src/LiveCoding/External.hs, interpreted )[11 of 38] Compiling LiveCoding.CellExcept ( src/LiveCoding/CellExcept.lhs, interpreted )[12 of 38] Compiling LiveCoding.Cell.Feedback ( src/LiveCoding/Cell/Feedback.lhs, interpreted )[13 of 38] Compiling LiveCoding.Cell.Util ( src/LiveCoding/Cell/Util.hs, interpreted )[14 of 38] Compiling LiveCoding.Bind ( src/LiveCoding/Bind.lhs, interpreted )[15 of 38] Compiling LiveCoding.Forever ( src/LiveCoding/Forever.lhs, interpreted )[16 of 38] Compiling LiveCoding.Debugger.StatePrint ( src/LiveCoding/Debugger/StatePrint.hs, interpreted )[17 of 38] Compiling LiveCoding.LiveProgram.Monad.Trans ( src/LiveCoding/LiveProgram/Monad/Trans.hs, interpreted )[18 of 38] Compiling LiveCoding.Handle ( src/LiveCoding/Handle.hs, interpreted )[19 of 38] Compiling LiveCoding.Handle.Examples ( src/LiveCoding/Handle/Examples.hs, interpreted )[20 of 38] Compiling LiveCoding.Cell.NonBlocking ( src/LiveCoding/Cell/NonBlocking.hs, interpreted )[21 of 38] Compiling LiveCoding.Migrate.Migration ( src/LiveCoding/Migrate/Migration.hs, interpreted )[22 of 38] Compiling LiveCoding.Migrate.Debugger ( src/LiveCoding/Migrate/Debugger.hs, interpreted )[23 of 38] Compiling LiveCoding.Migrate.Cell ( src/LiveCoding/Migrate/Cell.hs, interpreted )[24 of 38] Compiling LiveCoding.Migrate.Monad.Trans ( src/LiveCoding/Migrate/Monad/Trans.hs, interpreted )[25 of 38] Compiling LiveCoding.Migrate ( src/LiveCoding/Migrate.lhs, interpreted )[26 of 38] Compiling LiveCoding.LiveProgram.HotCodeSwap ( src/LiveCoding/LiveProgram/HotCodeSwap.lhs, interpreted )[27 of 38] Compiling LiveCoding.Cell.HotCodeSwap ( src/LiveCoding/Cell/HotCodeSwap.hs, interpreted )[28 of 38] Compiling LiveCoding.Preliminary.CellExcept.Applicative ( src/LiveCoding/Preliminary/CellExcept/Applicative.lhs, interpreted )[29 of 38] Compiling LiveCoding.Preliminary.CellExcept ( src/LiveCoding/Preliminary/CellExcept.lhs, interpreted )[30 of 38] Compiling LiveCoding.Preliminary.CellExcept.Monad ( src/LiveCoding/Preliminary/CellExcept/Monad.lhs, interpreted )[31 of 38] Compiling LiveCoding.Preliminary.CellExcept.Newtype ( src/LiveCoding/Preliminary/CellExcept/Newtype.lhs, interpreted )[32 of 38] Compiling LiveCoding.Preliminary.LiveProgram.LiveProgram2 ( src/LiveCoding/Preliminary/LiveProgram/LiveProgram2.lhs, interpreted )[33 of 38] Compiling LiveCoding.Preliminary.LiveProgram.LiveProgramPreliminary ( src/LiveCoding/Preliminary/LiveProgram/LiveProgramPreliminary.lhs, interpreted )[34 of 38] Compiling LiveCoding.Preliminary.LiveProgram.HotCodeSwap ( src/LiveCoding/Preliminary/LiveProgram/HotCodeSwap.lhs, interpreted )[35 of 38] Compiling LiveCoding.RuntimeIO.Launch ( src/LiveCoding/RuntimeIO/Launch.hs, interpreted )[36 of 38] Compiling LiveCoding.RuntimeIO ( src/LiveCoding/RuntimeIO.lhs, interpreted )[37 of 38] Compiling LiveCoding.GHCi ( src/LiveCoding/GHCi.hs, interpreted )[38 of 38] Compiling LiveCoding ( src/LiveCoding.hs, interpreted )Ok, 38 modules loaded.*LiveCoding>
I then type:
*LiveCoding> import Liv
And hit the Tab key, which autocompletes to:
*LiveCoding> import LiveCoding
I thought it worth being explicit about this, since you say "Enter the nix-shell", but I'm not entirely sure if I'm doing so in accordance with your expectations. (I don't use Nix to do daily development, so I might be using it differently than you are.)
Is there a way to be absolutely certain that we're using the same GHC binary?
Here is what type ghc reports within the Nix shell:
$ type ghcghc is /nix/store/smk3b8yj4c50643f4nsn6dyy7wzrvqzy-ghc-8.8.4-with-packages/bin/ghc$ ghc --versionThe Glorious Glasgow Haskell Compilation System, version 8.8.4
At some point I did gen-hie > hie.yaml or similar, maybe that makes a difference?
I'm not sure. As noted above, I followed your instructions using a clean checkout with no other changes, so it may be worth verifying that you trigger the panic using the same steps that I undertook.
Are you using NixOS or another system? Even Linux?
I believe your way to reproduce, in particular your nix usage, is correct. I have exactly the same GHC binary (unless nix is broken, which I don't believe in this case):
$ type ghcghc is /nix/store/smk3b8yj4c50643f4nsn6dyy7wzrvqzy-ghc-8.8.4-with-packages/bin/ghc$ ghc --versionThe Glorious Glasgow Haskell Compilation System, version 8.8.4
My call to cabal repl looks pretty much like yours, and the error persists even if I do rm -rf dist* && cabal clean first. I also had two files, hie.yaml and .ghci, in the root directory, which I removed, with no effect.
$ cabal replWarning: The package list for 'hackage.haskell.org' is 15 days old.Run 'cabal update' to get the latest list of available packages.Resolving dependencies...Build profile: -w ghc-8.8.4 -O1In order, the following will be built (use -v for more details): - essence-of-live-coding-0.2.4 (lib) (first run)Configuring library for essence-of-live-coding-0.2.4..Preprocessing library for essence-of-live-coding-0.2.4..GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help[ 1 of 38] Compiling LiveCoding.LiveProgram ( src/LiveCoding/LiveProgram.lhs, interpreted )[ 2 of 38] Compiling LiveCoding.Cell ( src/LiveCoding/Cell.lhs, interpreted )[ 3 of 38] Compiling LiveCoding.Debugger ( src/LiveCoding/Debugger.lhs, interpreted )[ 4 of 38] Compiling LiveCoding.Coalgebra ( src/LiveCoding/Coalgebra.lhs, interpreted )[ 5 of 38] Compiling LiveCoding.Cell.Monad ( src/LiveCoding/Cell/Monad.hs, interpreted )[ 6 of 38] Compiling LiveCoding.Cell.Resample ( src/LiveCoding/Cell/Resample.hs, interpreted )[ 7 of 38] Compiling LiveCoding.Cell.Monad.Trans ( src/LiveCoding/Cell/Monad/Trans.hs, interpreted )[ 8 of 38] Compiling LiveCoding.Exceptions.Finite ( src/LiveCoding/Exceptions/Finite.lhs, interpreted )[ 9 of 38] Compiling LiveCoding.Exceptions ( src/LiveCoding/Exceptions.lhs, interpreted )[10 of 38] Compiling LiveCoding.External ( src/LiveCoding/External.hs, interpreted )[11 of 38] Compiling LiveCoding.CellExcept ( src/LiveCoding/CellExcept.lhs, interpreted )[12 of 38] Compiling LiveCoding.Cell.Feedback ( src/LiveCoding/Cell/Feedback.lhs, interpreted )[13 of 38] Compiling LiveCoding.Cell.Util ( src/LiveCoding/Cell/Util.hs, interpreted )[14 of 38] Compiling LiveCoding.Bind ( src/LiveCoding/Bind.lhs, interpreted )[15 of 38] Compiling LiveCoding.Forever ( src/LiveCoding/Forever.lhs, interpreted )[16 of 38] Compiling LiveCoding.Debugger.StatePrint ( src/LiveCoding/Debugger/StatePrint.hs, interpreted )[17 of 38] Compiling LiveCoding.LiveProgram.Monad.Trans ( src/LiveCoding/LiveProgram/Monad/Trans.hs, interpreted )[18 of 38] Compiling LiveCoding.Handle ( src/LiveCoding/Handle.hs, interpreted )[19 of 38] Compiling LiveCoding.Handle.Examples ( src/LiveCoding/Handle/Examples.hs, interpreted )[20 of 38] Compiling LiveCoding.Cell.NonBlocking ( src/LiveCoding/Cell/NonBlocking.hs, interpreted )[21 of 38] Compiling LiveCoding.Migrate.Migration ( src/LiveCoding/Migrate/Migration.hs, interpreted )[22 of 38] Compiling LiveCoding.Migrate.Debugger ( src/LiveCoding/Migrate/Debugger.hs, interpreted )[23 of 38] Compiling LiveCoding.Migrate.Cell ( src/LiveCoding/Migrate/Cell.hs, interpreted )[24 of 38] Compiling LiveCoding.Migrate.Monad.Trans ( src/LiveCoding/Migrate/Monad/Trans.hs, interpreted )[25 of 38] Compiling LiveCoding.Migrate ( src/LiveCoding/Migrate.lhs, interpreted )[26 of 38] Compiling LiveCoding.LiveProgram.HotCodeSwap ( src/LiveCoding/LiveProgram/HotCodeSwap.lhs, interpreted )[27 of 38] Compiling LiveCoding.Cell.HotCodeSwap ( src/LiveCoding/Cell/HotCodeSwap.hs, interpreted )[28 of 38] Compiling LiveCoding.Preliminary.CellExcept.Applicative ( src/LiveCoding/Preliminary/CellExcept/Applicative.lhs, interpreted )[29 of 38] Compiling LiveCoding.Preliminary.CellExcept ( src/LiveCoding/Preliminary/CellExcept.lhs, interpreted )[30 of 38] Compiling LiveCoding.Preliminary.CellExcept.Monad ( src/LiveCoding/Preliminary/CellExcept/Monad.lhs, interpreted )[31 of 38] Compiling LiveCoding.Preliminary.CellExcept.Newtype ( src/LiveCoding/Preliminary/CellExcept/Newtype.lhs, interpreted )[32 of 38] Compiling LiveCoding.Preliminary.LiveProgram.LiveProgram2 ( src/LiveCoding/Preliminary/LiveProgram/LiveProgram2.lhs, interpreted )[33 of 38] Compiling LiveCoding.Preliminary.LiveProgram.LiveProgramPreliminary ( src/LiveCoding/Preliminary/LiveProgram/LiveProgramPreliminary.lhs, interpreted )[34 of 38] Compiling LiveCoding.Preliminary.LiveProgram.HotCodeSwap ( src/LiveCoding/Preliminary/LiveProgram/HotCodeSwap.lhs, interpreted )[35 of 38] Compiling LiveCoding.RuntimeIO.Launch ( src/LiveCoding/RuntimeIO/Launch.hs, interpreted )[36 of 38] Compiling LiveCoding.RuntimeIO ( src/LiveCoding/RuntimeIO.lhs, interpreted )[37 of 38] Compiling LiveCoding.GHCi ( src/LiveCoding/GHCi.hs, interpreted )[38 of 38] Compiling LiveCoding ( src/LiveCoding.hs, interpreted )Ok, 38 modules loaded.*LiveCoding> import Livghc: panic! (the 'impossible' happened) (GHC version 8.8.4 for x86_64-unknown-linux): ModOrigin: hidden module redefinedPlease report this as a GHC bug: https://www.haskell.org/ghc/reportabugLeaving GHCi.
I have this:
$ ghc-pkg checkWarning: haddock-interfaces: /nix/store/sj101xblxzrp331xxcl7xiph5nwfq4bx-nats-1.1.2/share/doc/x86_64-linux-ghc-8.8.4/nats-1.1.2/html/nats.haddock doesn't exist or isn't a fileWarning: haddock-html: /nix/store/sj101xblxzrp331xxcl7xiph5nwfq4bx-nats-1.1.2/share/doc/x86_64-linux-ghc-8.8.4/nats-1.1.2/html doesn't exist or isn't a directoryWarning: haddock-interfaces: /nix/store/jb1pdmbhvknjlb0nqlrwx4fmqvqh5pw0-vault-0.3.1.4/share/doc/x86_64-linux-ghc-8.8.4/vault-0.3.1.4/html/vault.haddock doesn't exist or isn't a fileWarning: haddock-html: /nix/store/jb1pdmbhvknjlb0nqlrwx4fmqvqh5pw0-vault-0.3.1.4/share/doc/x86_64-linux-ghc-8.8.4/vault-0.3.1.4/html doesn't exist or isn't a directory
But to be honest I don't know what it means or how I can deal with it.
I have the same ghc-pkg check warnings, so I doubt that this is the culprit. And since the original reporter was using GHC 8.6, which predates .hie files, I doubt that hie.yaml is to blame. Nor do I strongly suspect .ghci, as I was unable to reproduce the bug with or without my own ~/.ghci file present. It's definitely a good idea to remove them for testing purposes, however.
Just to be clear, are you able to reproducing the bug from a 100% clean checkout, like I do in #16996 (comment 302756)? The fact that you mention hie.yaml and .ghci files (which aren't checked in to the repo, AFAICT) makes me believe that you performed some other steps that are critical to triggering this bug, so I want to make sure that we are on the same page.
Yes, even from a 100% clean checkout, the error occurs.
But I have to name a success though: When I move away my ~/.cabal folder and reinitialize it, the error goes away! So apparently some state in there messed up my system.
Do you want me to share the old folder, or look for something specific in there?
But I have to name a success though: When I move away my ~/.cabal folder and reinitialize it, the error goes away! So apparently some state in there messed up my system.
Interesting. I'm not sure if it's feasible to share your entire ~/.cabal folder (they typically grow to be quite large), but if you can, that would be one possible way to debug this further. In addition to that, you might also try migrating specific files from your moved-away ~/.cabal folder back to ~/.cabal to see if you can pinpoint which thing in particular is causing the panic.
switch to an empty directory, then use $ nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [ base cabal-install ])" to create a development shell
in the shell just created: $ cabal init && cabal repl
In ghci, type :m , then press Tab as discussed above:
λ> :m ghc: panic! (the 'impossible' happened) (GHC version 8.10.3: ModOrigin: hidden module redefinedPlease report this as a GHC bug: https://www.haskell.org/ghc/reportabugLeaving GHCi.
The error will disappear if I remove ~/.cabal/store.
I suspect it was caused by mixing packages in nix environment
and cabal store though without sufficient evidence.